What's the best way to convert a FlowDocument into PDF
I am assuming you want this to occur programmatically rather than as a manual process.
Method 1: Install a PDF driver such as Amyuni or PrimoPDF. Print your FlowDocument with the desired PrintTicket / page size, to the print driver. The PDF you get from it should be a fairly good conversion. Some of these drivers (such as Amyuni) have SDKs that you can control this process programmatically.
Method 2: Print to XPS programmatically using an XPS driver without a Save As dialog; there's a sample for this in the Windows DDK you can build yourself fairly easily. Then use an XPS to PDF converter such as NiXPS or the Adobe SDK (so expensive I won't post a link) or GhostXPS to convert the XPS directly to PDF.
Method 3: Convert the flow document directly into XPS using methods like This one and then use an XPS to PDF converter such as the ones mentioned above.
Disclaimer: I don't work for any of these companies or their competitors. I've used the Adobe SDK, the Amyuni printer, and various XPS tricks with fairly good success. No method will convert with 100% accuracy.
Disclaimer: I am writer of XamlToPDF Library, however it is free for any type of use.
http://xamltopdf.codeplex.com/
Its very easy to create PDF, it supports Tables and images as well.
You have two options that I know of.
The first is to use a proprietary library called NiPDF, alternatively you can use Word Interop.
- Save the FlowDocument to a DOCX file using Open XML SDK
- Use Word Interop to load the saved document from some temporary store
- Set the WdSaveFormat to wdFormatPDF
- Save the document again (remember to rename the file to PDF)
You can find further info here