how to draw a Arabic text on pdf page?
Syncfusion.Pdf.Graphics.PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = Syncfusion.Pdf.Graphics.PdfTextAlignment.Left;
SyncfusionGraphics.PdfTextElement text = new SyncfusionGraphics.PdfTextElement()
{
"سیتوژنتیک"
Font = font,
StringFormat = format,
Brush = this.GetPdfBrush(textBlockInfo.FontColor)
};
text.Draw(page, position,
page.Size.Width - page.Section.PageSettings.Margins.Left - page.Section.PageSettings.Margins.Right, layoutFormat);
I tried your source code, the Arabic text display. But when I use below test case, the chars "基因遗传学" was lost, do you know how to resolve this issue?
PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();
PdfStringFormat format = new PdfStringFormat();
format.Alignment = PdfTextAlignment.Left;
PdfTextElement text = new PdfTextElement();
text.Text = "559_XXXXXRegionsOfInterestسیتوژنتیک基因遗传学_.hg19.bed";
text.Font = new PdfTrueTypeFont(new Font("Arial", 10f), true);
text.StringFormat = format;
text.Brush = PdfBrushes.Black;
text.Draw(page, PointF.Empty);
document.Save("Sample.pdf");
document.Close(true);
The attachment file is my test restult.
Thanks
Steven
Sample_7e969cd3.zip
Hi Geetha
I am using Syncfusion.Xamarin.Pdf 20.2.0.50.
As you have mentioned above ,
text.Font = new PdfTrueTypeFont(new Font("Arial", 10f), true); is not supporting .
Can you help me to drow arabic string in my pdf document
We can draw the Arabic text with right-to-left (RTL) format in a PDF document in Xamarin Platform. We have to embed the font files in Xamarin Forms application by setting the build action to embedded resource. Please follow the below steps in your end and let us know if it is suites your requirement or not,
- Include the supported font file into the Assets folder.
- Right click the font file and Go to properties and Set Build Action to Embedded resource and copy always
Please find the below screenshot,
|
|
Note: Please make sure the using font file should supports
the Arabic text or not. We have to use the supported font file to preserve the
text properly.
Please refer the below link for more information,
https://www.syncfusion.com/blogs/post/adding-rtl-support-to-your-pdf-in-xamarin.aspx
https://support.syncfusion.com/kb/article/8560/how-to-draw-unicode-characters-in-a-pdf-in-xamarin
We have attached the simple sample to draw a Arabic and English text for your reference, please try the sample on your end and let us know the result.
- 5 Replies
- 4 Participants
-
SH Steven Hongbin Zhou
- Jun 7, 2012 11:30 AM UTC
- May 1, 2023 01:20 PM UTC