Category / Section
How to use custom fonts in PDF?
1 min read
You can have custom fonts in the PDF by using the PdfTrueTypeFont class available under the namespace, Syncfusion.Pdf.Graphics. You have to initialize the PdfTrueTypefont with input font file. Refer to the following code example.
C#
//Creating the PDF document. PdfDocument document = new PdfDocument(); //Adding the page. PdfPage page = document.Pages.Add(); //Loading the custom TTF font. PdfFont font = new PdfTrueTypeFont(Server.MapPath("/App_Data/ARIALUNI.ttf"), 24); //Drawing the Unicode string. page.Graphics.DrawString("Hello PDF Sample", font, PdfBrushes.Black, 100, 100); //Saving the document. document.Save("Sample.pdf", Response, HttpReadType.Save); //Closing the document. document.Close();
Sample Link:
http://www.syncfusion.com/downloads/support/directtrac/general/Custom_font1254741175.zip