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

139 views
Skip to first unread message

Support

unread,
Oct 21, 2011, 12:45:28 PM10/21/11
to pdfne...@googlegroups.com
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 http://www.pdftron.com/pdfnet/samplecode/data/Text2PDF.zip

 

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 (http://www.pdftron.com/pdfnet/

samplecode.html#Xaml2Pdf)

 

c) Finally, you can warp the text into HTML body and convert the resulting string to PDF / Silverlight as shown in Html2Pdf sample http://www.pdftron.com/pdfnet/samplecode.html#Html2Pdf.

Support

unread,
Oct 21, 2011, 12:49:15 PM10/21/11
to pdfne...@googlegroups.com
 
Actually for the HTML2PDF solution (c),  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().
Reply all
Reply to author
Forward
0 new messages