Hi
I have followed your tutorial (with the free library) to fill in a Arabic PDF form with Arabic content.
When I open the saved PDF , the field content write split character like مرحبا it write م ر ح ب ا .
What am I doing wrong?
Saif
rachel.lei wrote:Hello,
Greetings from E-iceblue!
How is your issue now? Could you please provide more information to help us further look into your issue?
Thanks in advance.
Sincerely,
Rachel
E-iceblue support team
PdfDocument doc = new PdfDocument();
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin);
float y = 10;
PdfBrush brush1 = PdfBrushes.Black;
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("./Alef-Regular.ttf", 16f, FontStyle.Bold), true);
PdfStringFormat format1 = new PdfStringFormat() { RightToLeft = true, Alignment = PdfTextAlignment.Center };
page.Canvas.DrawString("دول العالم", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
y = y + font1.MeasureString("دول العالم", format1).Height;
y = y + 5;
String[] data
= {
"الاسم;العاصمه;الدوله;المنطقه;تعداد السكان",
"Argentina;Buenos Aires;South America;2777815;32300003",
"Bolivia;La Paz;South America;1098575;7300000",
"Brazil;Brasilia;South America;8511196;150400000",
"Canada;Ottawa;North America;9976147;26500000",
};
String[][] dataSource
= new String[data.Length][];
for (int i = 0; i < data.Length; i++)
{
dataSource[i] = data[i].Split(';');
}
PdfTable table = new PdfTable();
table.Style.CellPadding = 2;
table.Style.HeaderSource = PdfHeaderSource.Rows;
table.Style.HeaderRowCount = 1;
table.Style.ShowHeader = true;
table.DataSource = dataSource;
table.Style.HeaderStyle.Font = new PdfTrueTypeFont(new Font("./Alef-Regular.ttf", 16f, FontStyle.Bold), true);
table.Style.HeaderStyle.StringFormat = new PdfStringFormat() { RightToLeft = true, Alignment = PdfTextAlignment.Center };
PdfLayoutResult result = table.Draw(page, new PointF(0, y));
y = y + result.Bounds.Height + 5;
PdfBrush brush2 = PdfBrushes.Gray;
PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("./Alef-Regular.ttf", 16f, FontStyle.Bold), true);
page.Canvas.DrawString(String.Format("* {0} countries in the list.", data.Length - 1), font2, brush2, 5, y);
doc.SaveToFile("SimpleTable.pdf");
doc.Close();
const string value = "أهلا وسهلا";
var doc = new PdfDocument();
var page = doc.Pages.Add(PdfPageSize.A4, new PdfMargins());
var font = new PdfTrueTypeFont(new Font("Alef-Regular.ttf", 36f, FontStyle.Bold), true);
var labelBounds = new RectangleF(20, 20, 400, font.Height);
page.Canvas.DrawString(value, font, PdfBrushes.Black, labelBounds, new PdfStringFormat() { RightToLeft = true });
doc.SaveToFile("result3.pdf");
//Method1: Need to install the corresponding font in your system
var font = new PdfTrueTypeFont(new Font("Alef", 16f, FontStyle.Bold), true);
//Method2: Don’t need to install the corresponding font in your system
var font = new PdfTrueTypeFont("Fonts/Alef-Regular.ttf", 16f);
rachel.lei wrote:Hello,
Hope you are doing well.
Have you tested the latest Spire.PDF? Did it solve your issue?
Thanks in advance for your feedback.
Sincerely,
Rachel
E-iceblue support team