Convert XHTML to PDF

Generate PDF, HTML / CSS
5/15/2015

Downloads

This code sample shows how to add a note to a PDF document.

C#

1 Document document = new Document(); 2 Section section = document.Sections.Add(); 3 4 XhtmlParagraph xhtmlParagraph = new XhtmlParagraph(); 5 6 ConversionSettings conversionSettings = new ConversionSettings(); 7 conversionSettings.FontPath = @"..\fonts"; 8 9 xhtmlParagraph.Settings = conversionSettings; 10 xhtmlParagraph.Text = "<b><font color=\"brown\">Hello world!</font></b><br/>With this you can:<ul><li>Include xHTML compliant layout</li><li>Allow formatting content by (web)designers<br/>... and include it in your document</li></ul>"; 11 12 section.Paragraphs.Add(xhtmlParagraph); 13 14 using (var file = new FileStream(@"..\..\result.pdf", FileMode.Create, FileAccess.Write)) 15 { 16 document.Write(file); 17 }