Converting doc, docx, xls, xlsx, txt, Html, odt …. to a PDF via PDFNet SDK

Q:

We are wondering if your product will allow either a byte array or memory stream of any document type (IE: primarily doc, docx, xls, xlsx, txt, Html, odt …. ) to be converted to a PDF. We see that you convert a stream of an Xaml document.

We are storing our documents in a SQL Blob column (then reading them into either a byte array or memory stream) and need to convert them to a PDF and would like to do this without having to create a disk file in the middle.

Also can you provide us with a list of the document types that can be converted to a PDF

A:

As of PDFNet v.5.9 ‘pdftron.PDF.Convert.ToPdf()’ methods support only conversion via filename. This means that you would need to save a file to a temp file for conversion. The converted PDF files does need to be saved to disk however (PDFDoc.Save() method can be used to save to byte[] or a Stream).

Please note that some conversions such as Html2Pdf (for HTML, TXT), Image (Jpeg, TIFF, png, gif, etc see AddImage sample), XPS, Xaml, EMF/WMF, PDF do support conversion from a memory buffer or a stream so it is not always the case that you need to save the input file.

Ø can you provide us with a list of the document types that can be converted to a PDF

Microsoft Excel

XLA, XLAM, XLC, XLL, XLM, XLS, XLSB, XLSM, XLSX, XLT, XLTM, XLTX, XLW *

    • assumes MS Office is present. For conversion from MS Office we generally recommend that MS Office is present on the target machine/server. PDFNet can also convert via a generic virtual printer driver, however due to complicated configuration we are not actively supporting this use case.

I forgot to mention that PDFNet also includes a virtual printer driver that could be used to programmatically convert ‘any’ printable document to PDF, XPS, SVG, image, txt … provided that you have an app that can ‘print’ the file via “print verb” (http://msdn.microsoft.com/en-us/library/bb776883.aspx). This is how PDFNet can convert DOCX to PDF on Windows even without MS Office present (Wordpad that comes as part of Windows can print Docx). Please note however that the process of selecting an app the can reliably print files in unattended mode can be tricky or not depending on the file format and the available pool of apps.