How do I convert text file Txt to PDF file with PDFNet SDK?

Q: How do I convert Text Txt to PDF file with PDFNet SDK?

I tried pdftron.PDF.Convert.ToPDF() but it tries to print to PDF via notepad.

A: As part of the next update we will improve ToPDF to use direct conversion instead of virtaul driver for txt files.

In the meantime, there are multiple ways to convert TXT to PDF using PDFNet that do not require a virtual printer driver:

a) You can use low-level ElementBuilder and ElementWriter to place text on a PDF page as shown in

b) If you are developing under .NET you could place the text from TXT to a FlowDocument which you can convert to PDF and Silverlight XOD as shown in Xaml2Pdf sample (


c) Finally, you can warp the text into HTML body and convert the resulting string to PDF / Silverlight as shown in Html2Pdf sample

or the HTML2PDF solution ©, you do not need to wrap the contents of the text file with HTML tags. You can can pass the text file (path and filename) directly to HTML2PDF.Convert().