How to draw unicode character in the PDF Document in WinForms?
The Syncfusion .NET PDF library is used to create, read, and edit PDF documents. This library also offers functionality to merge, split, stamp, form, and secure PDF files. Using this library, you can draw Unicode characters in the PDF document using C#.
Steps to draw Unicode characters in the PDF document programmatically:
-
Create a new C# Windows Forms application project.
-
Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org.
-
Include the following namespaces in the Form1.cs file.
C#
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf;
using System;
using System.Drawing;
- Create the button1_Click event and add the below code sample in button1_Click to draw a Unicode character in the PDF document.
C#
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add new page.
PdfPage page = document.Pages.Add();
//Set the font.
PdfFont font = new PdfTrueTypeFont(new Font("Arial", 12, FontStyle.Regular), true);
//Create text element and assign text to be added.
PdfTextElement textElement = new PdfTextElement("Unicode characters ζζζζζ ωωωω α");
textElement.Font = font;
textElement.Brush = PdfBrushes.Black;
textElement.Draw(page, new PointF(10, 10));
//Save the document and dispose it.
document.Save("Output.pdf");
document.Close(true);
A complete working sample can be downloaded from the Draw-unicode-character-in-PDF.zip.
By executing the program, you will get a PDF document as follows.
Take a moment to peruse the documentation, where you can find features like PDF form filling, extract text from PDF document, Extract images from PDF document, and protect PDF documents, and more with code examples.
Refer to here to explore the rich set of Syncfusion Essential PDF features.
An online sample link to generate a simple PDF document.
Note: Starting with v16.2.0.x, if you reference Syncfusion assemblies from the trial setup or NuGet feed, include a license key in your projects. Refer to this link to learn about generating and registering the Syncfusion license key in your application to use the components without a trail message.
Conclusion
I hope you enjoyed learning about how to draw unicode character in the PDF Document in WinForms.
You can refer to our WinForms PDF feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms PDF example 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 check out 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, Direct-Trac, or feedback portal. We are always happy to assist you!