What are my options for PDF creation / generation using PDFTron SDK?

Q:

We need to add PDF report generation in our system/application. The new interface will take data currently going into our XML reports and programatically build a PDF document. The end goal is to produce a portable, attractive report document.

What are my options for PDF creation / generation using PDFTron?

A: PDFTron’s core library PDFNet SDK offers very comprehensive API for all type of PDF processing ranging from PDF generation, modification, templating, conversion, printing, rasterization, viewing, annotation, etc.

In terms of PDF generation there are multiple ways to produce PDF with PDFNet SDK:

The most powerful option is to use ElementBuilder and ElementWriter as shown in ElementBuilder sample:

http://www.pdftron.com/pdfnet/samplecode.html#ElementBuilder

ElementBuilder gives access to full PDF graphics state and can be used to control every aspect of PDF generation, but for some applications the API may be overkill (i.e. too much work).

In case you don’t need low-level of control, it may be simpler to generate content from HTML string (see HTML2PDF sample - http://www.pdftron.com/pdfnet/samplecode.html#Html2Pdf). XML/XSL should be simple to translate to HTML using existing .NET/Java framework tools.

In a similar manner, PDFNet also supports PDF generation from WPF Xaml and FlowDocuments (http://msdn.microsoft.com/en-us/library/aa970909.aspx). As a starting point you may want to take a look at Xaml2Pdf sample: http://www.pdftron.com/pdfnet/samplecode.html#Xaml2Pdf

PDFNet also supports PDF generation using GDI and GDI+ as shown in PDFDC sample: http://www.pdftron.com/pdfnet/samplecode.html#PDFDC

PDF can also be generated using direct converters from various formats (including EMF, XPS, TIFF, TXT, etc.), direct interop with MS Office, and from any application via virtual printer driver. All three types of conversion are demonstrated in the Convert sample project:

http://www.pdftron.com/pdfnet/samplecode.html#Convert

These are only starting references and PDFNet includes many other potentially useful features such as PDF generation from other PDF documents (e.g. PDF merging or imposition, or filling in PDF templates and forms based on dynamic data coming from databases or other sources) etc.

The generated PDF (including any other documents) can be viewed in built-in PDF Viewer (e.g. WinForm, WPF control) or can be viewd online with the help of SilverDox Publisher (http://www.pdftron.com/silverdox).