How to display unicode text in Pdf WinRT?
Essential PDF does not provide direct support for rendering Unicode text in WinRT platform. As WinRT does not provide access to installed font data, Unicode fonts cannot be embedded directly. Instead, the font file can be added as an embedded resource to the application, from where it can be embedded in the PDF Document.
You can use the PdfTrueTypeFont to display the Unicode font in the PDF, Please refer the below code snippet.
[C#]
Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;
//Gettin the fontdata
Stream fontData = assembly.GetManifestResourceStream("PdfUnicodeFontSample.Assets.arial.ttf");
//creating the docuement
PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();
//creating the true type font
PdfTrueTypeFont font = new PdfTrueTypeFont(fontData, 20);
//drawing the string
page.Graphics.DrawString("Sample@#% unicode test%3^*", font, PdfBrushes.Red, 0, 0);
MemoryStream stream = new MemoryStream();
//saving the document
document.Save(stream);
Save(stream);
Sample:
The below sample shows how to add a font file as embedded resource and how the Unicode text can be drawn to the PDF document.
https://www.syncfusion.com/downloads/support/directtrac/general/PdfUnicodeFontSample1174984094.zip
Note:
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.
Conclusion:
I hope you enjoyed learning about how to display Unicode text in Pdf WinRT.
You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!