Hello Syncfusion, I am trying to use SyncfusionGraphics.PdfTextElement to draw a Arabic text( توفير خدمات التمثيل التجاري هدفها زيادة رقم اعمال الشركة. ) on pdf page, but all of the text do not appear (Blank page) when i set The
TextDirection
to RightToLeft ,so how to draw a Arabic text on pdf page? below is my code:
Note Im using Android API29
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new PDF page.
PdfPage page = document.Pages.Add();
//Create new PdfTrueTypeFont instance.
//Load the font from assets.
Stream fontStream = typeof(App).GetTypeInfo().
Assembly.GetManifestResourceStream
("BrokerApp.Fonts.Arial.ttf"); PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 22);
//Create a PdfStringFormat.
PdfStringFormat format = new PdfStringFormat();
//Set text direction.
format.TextDirection = PdfTextDirection.RightToLeft;
//Set text alignment.
format.Alignment = PdfTextAlignment.Right;
//format.Alignment = PdfTextAlignment.Left;
PdfTextElement text = new PdfTextElement();
text.Text = "بالعالم مرحبا !";
text.Font = new PdfTrueTypeFont(fontStream, 15);
text.StringFormat = format;
text.Brush = PdfBrushes.Black;
text.Draw(page, PointF.Empty);
//Save document.
MemoryStream ms = new MemoryStream();
document.Save(ms);
//Close the PdfDocument instance.
document.Close(true);
//BrokerApp.Fonts.Arial.ttf
Xamarin.Forms.DependencyService.Get<ISave>().SaveAndView("Text.pdf", "application/pdf", ms);
|
string text = "بالعالم مرحبا !";
PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12);
//Create a PdfStringFormat.
PdfStringFormat format = new PdfStringFormat();
//Set text direction.
format.TextDirection = PdfTextDirection.RightToLeft;
//Set text alignment.
format.Alignment = PdfTextAlignment.Right;
SizeF pageSize = page.GetClientSize();
//Draw text to the PDF document.
page.Graphics.DrawString(text, font, PdfBrushes.Black, new Syncfusion.Drawing.RectangleF(0, 0, pageSize.Width, pageSize.Height), format);
|