я использую spire.pdf на платформе xamarin, цель – экспортировать данные в формате PDF. Код, который будет добавлен ниже, работает отлично, но я столкнулся с проблемой с арабским языком.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Tables;
using System.Drawing;
using Spire.Pdf.ColorSpace;
using System.Collections.ObjectModel;
using System.Data;
namespace Test2
{
public partial class MainPage : ContentPage
{
List cars;
public MainPage()
{
InitializeComponent();
cars = new List()
{
new Car{ Name="مرسيدس",Model="E350",Color="Brown"},
new Car{ Name="BMW",Model="i530",Color="Red"},
new Car{ Name="Toyota",Model="Corolla",Color="White"},
new Car{ Name="Hunda",Model="Civic",Color="Silver"},
new Car{ Name="Toyota",Model="Carina",Color="Green"}
};
}
private void btnPrint_Clicked(object sender, EventArgs e)
{
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Add a page
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins(40));
//Create a PdfTable object
PdfTable table = new PdfTable();
//Draw the text - alignment
PdfTrueTypeFont font = new PdfTrueTypeFont("Arial", 12f,PdfFontStyle.Bold,true);
PdfSolidBrush brush = new PdfSolidBrush(System.Drawing.Color.Blue);
PdfStringFormat rightAlignment = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
page.Canvas.DrawString("عبدالله للتجارة والمقاولات", font, brush, page.Canvas.ClientSize.Width, 30, rightAlignment);
page.Canvas.DrawString("نقليات-حفريات-مواد بناء", font, brush, page.Canvas.ClientSize.Width, 60, rightAlignment);
//Set font for header and the rest cells
table.Style.DefaultStyle.Font = new PdfTrueTypeFont("Arial", 12f, PdfFontStyle.Regular,true);
table.Style.HeaderStyle.Font = new PdfTrueTypeFont("Arial", 12f, PdfFontStyle.Bold,true);
//The data presented by list converted to datatable
ListtoDataTableConverter converter = new ListtoDataTableConverter();
DataTable dt = converter.ToDataTable(cars);
//Set the datatable as the data source of table
table.DataSource = dt;
//Show header(the header is hidden by default)
table.Style.ShowHeader = true;
//Set font color and backgroud color of header row
table.Style.HeaderStyle.BackgroundBrush = PdfBrushes.Gray;
table.Style.HeaderStyle.TextBrush = PdfBrushes.White;
//Set text alignment in header row
table.Style.HeaderStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//Set text alignment in other cells
for (int i = 0; i < table.Columns.Count; i++)
{
table.Columns[i].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
}
//Register with BeginRowLayout event
table.BeginRowLayout += Table_BeginRowLayout;
//Draw table on the page
table.Draw(page, new PointF(0, 80));
doc.SaveToFile("/storage/emulated/0/Download/2.pdf");
DisplayAlert("Create PDF", "PDF has been created succcessfully", "OK");
}
//Event handler
private static void Table_BeginRowLayout(object sender, BeginRowLayoutEventArgs args)
{
//Set row height
args.MinimalHeight = 20f;
//Alternate row color
if (args.RowIndex < 0)
{
return;
}
if (args.RowIndex % 2 == 1)
{
args.CellStyle.BackgroundBrush = PdfBrushes.LightGray;
}
else
{
args.CellStyle.BackgroundBrush = PdfBrushes.White;
}
}
}
}
тестирую приложение на своем физическом телефоне Samsung Galaxy M12.
Я думал, что проблема связана с типом шрифта на моем физическом телефоне, поэтому я попытался изменить значение по умолчанию, но не знал, как это сделать, потому что вы можете выбрать экономичные или фиксированные шрифты.
я использую spire.pdf на платформе xamarin, цель – экспортировать данные в формате PDF. Код, который будет добавлен ниже, работает отлично, но я столкнулся с проблемой с арабским языком. [code]using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using Spire.Pdf; using Spire.Pdf.Graphics; using Spire.Pdf.Tables; using System.Drawing; using Spire.Pdf.ColorSpace; using System.Collections.ObjectModel; using System.Data;
namespace Test2 { public partial class MainPage : ContentPage { List cars; public MainPage() { InitializeComponent(); cars = new List() { new Car{ Name="مرسيدس",Model="E350",Color="Brown"}, new Car{ Name="BMW",Model="i530",Color="Red"}, new Car{ Name="Toyota",Model="Corolla",Color="White"}, new Car{ Name="Hunda",Model="Civic",Color="Silver"}, new Car{ Name="Toyota",Model="Carina",Color="Green"} }; }
//Create a PdfDocument object PdfDocument doc = new PdfDocument();
//Add a page PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins(40));
//Create a PdfTable object PdfTable table = new PdfTable();
//Draw the text - alignment PdfTrueTypeFont font = new PdfTrueTypeFont("Arial", 12f,PdfFontStyle.Bold,true); PdfSolidBrush brush = new PdfSolidBrush(System.Drawing.Color.Blue);
//Set font for header and the rest cells table.Style.DefaultStyle.Font = new PdfTrueTypeFont("Arial", 12f, PdfFontStyle.Regular,true); table.Style.HeaderStyle.Font = new PdfTrueTypeFont("Arial", 12f, PdfFontStyle.Bold,true);
//The data presented by list converted to datatable ListtoDataTableConverter converter = new ListtoDataTableConverter(); DataTable dt = converter.ToDataTable(cars);
//Set the datatable as the data source of table table.DataSource = dt;
//Show header(the header is hidden by default) table.Style.ShowHeader = true;
//Set font color and backgroud color of header row table.Style.HeaderStyle.BackgroundBrush = PdfBrushes.Gray; table.Style.HeaderStyle.TextBrush = PdfBrushes.White;
//Set text alignment in header row table.Style.HeaderStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//Set text alignment in other cells for (int i = 0; i < table.Columns.Count; i++) { table.Columns[i].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle); }
//Register with BeginRowLayout event table.BeginRowLayout += Table_BeginRowLayout;
//Draw table on the page table.Draw(page, new PointF(0, 80));
doc.SaveToFile("/storage/emulated/0/Download/2.pdf"); DisplayAlert("Create PDF", "PDF has been created succcessfully", "OK"); }
//Alternate row color if (args.RowIndex < 0) { return; } if (args.RowIndex % 2 == 1) { args.CellStyle.BackgroundBrush = PdfBrushes.LightGray; } else { args.CellStyle.BackgroundBrush = PdfBrushes.White; } } } }
[/code] тестирую приложение на своем физическом телефоне Samsung Galaxy M12. Я думал, что проблема связана с типом шрифта на моем физическом телефоне, поэтому я попытался изменить значение по умолчанию, но не знал, как это сделать, потому что вы можете выбрать экономичные или фиксированные шрифты.
Я пытался создать PDF-документы со смешанным содержанием на арабском и английском языках, но всегда получал перевернутый арабский текст. Я пробовал itext (без PDFCalligraph), pPDFBox с тем же результатом. Сегодня я наткнулся на OpenHtmltoPdf и его...
У меня есть файл в кодировке UTF-8, проблемная строка:
39b3efee-e5c8-428e-94f3-74740220c618 = หลวงประดิษฐไพเราะ (ศร ศิลปบรรเลง)
В Windows в приложении «Блокнот» отображается нормально.
.png
Но когда я загружаю его в приложение Java в JTextArea,...
Когда я пытаюсь преобразовать дату на арабский язык с помощью приведенного ниже кода и кода языка ar_AE, дата отображается западными цифрами, а не на арабском языке.
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium...
У меня есть функциональность, чтобы сначала показать сборщика года. Затем весь календарь использует локализацию, но когда я меняю язык устройства на арабский язык, дата «годы» не развивается на арабский язык. Некоторые значения отображаются на...
У меня есть функциональность, чтобы сначала показать сборщика года. Затем весь календарь использует локализацию, но когда я меняю язык устройства на арабский язык, дата «годы» не развивается на арабский язык. Некоторые значения отображаются на...