Arabic text not drawing

Stream fontStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("pdffont.ttf");

PdfFont font1 = new PdfTrueTypeFont(fontStream, font.Size);

PdfTextElement text_element = new PdfTextElement();

text_element.Text = "Arabic and english text together";

text_element.Font = font1;

text_element.StringFormat = new PdfStringFormat(align) { ComplexScript = true };

text_element.Brush = brush;

text_element.Draw(page, rectangleF);


Above code is drowing english content but arabic is showing as blank


//my pdffont.ttf is copied in Asset folder



1 Reply

GK Gowthamraj Kumar Syncfusion Team May 1, 2023 01:15 PM UTC

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 with output document for your reference, please try the sample on your end and let us know the result.


Attachment: CreatePDFwithArabixTextSample_9b2a0a5b.zip

Loader.
Up arrow icon