PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

XhtmlParagraph and TrueType fonts

The following code converts XHTML to PDF using the XhtmlParagraph. The HTML specfies Georgia as the font to use using an inline style attribute. The FontPath property of ConversionSettings instructs XhtmlParagraph to use the fonts inside this folder.

Document document = new Document();
Section section = document.Sections.Add();
XhtmlParagraph xhtml = new XhtmlParagraph();

xhtml.Text = File.ReadAllText(@"in.html");
xhtml.Settings = new ConversionSettings { FontPath = @"d:\fonts" };

using (FileStream file = new FileStream("out.pdf", FileMode.Create))

Document in.html looks as follows:

        <p style="font-family: Georgia">Hello world</p>
Download TallPDF.NET 5.0
We will send you a download link

  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.