How do I convert HTML to PDF with vector graphics or replace raster images in existing PDFs with vector equivalants?

Q: I am looking to purchase a PDF library which can assist us with
improving image quality in our financial report PDFs that are
generated internally (using an in house developed solution written in
C#).

The output of the application is Document.pdf - we need to loop
through the images in this file and replace with either EMF or the
equivalent in a PDF format (see graph.pdf). We can generate the PDF or
EMF (Metafile.emf, we can also convert to SVG, EPS, PS, PDF, SWF,
HPGL, PCL if any of those formats are better) for every graph that
needs to be inserted, do you have a solution that will allow us to
replace the original images for the vector equivalents?

Alternatively if this is difficult - we generate the PDF from HTML at
the moment, page by page … I have complete control over how the HTML
is generated and the elements inserted, but we use a third party
solution to convert the pages to HTML at the moment, and it doesn’t
support vector graphics of any kind. If you have a solution that will
allow us to HTML to PDF while maintaining vector image quality then
this would also be extremely useful.


A: Since you are generating PDF from HTML you may want to try using
‘pdftron.PDF.Html2Pdf’ as shown in ‘Html2Pdf’ sample project (http://
www.pdftron.com/pdfnet/samplecode.html#Html2Pdf). Html2Pdf supports
embedded SVG so your graphs could come through
as vector graphics instead of raster images.

PDFNet also supports conversion from WPF Xaml (as shown in Xaml2Pdf
sample http://www.pdftron.com/pdfnet/samplecode.html#Xaml2Pdf) as well
import from EMF (using pdftron.PDF.Convert.FromEmf(doc, “my.emf”).

You can also replace existing raster images with their vector
equivalents as described in the following articles:

http://groups.google.com/group/pdfnet-sdk/t/a16940d74b8339d9
http://groups.google.com/group/pdfnet-sdk/t/573c346440715cd7
http://groups.google.com/group/pdfnet-sdk/t/97518181dae34e6

The discussion in these articles relates to replacing raster images
with other raster images but the same technique
(doc.GetSDFDoc().Swap(obj1, obj2)) can be used with any XObject (such
as Form). To create a Form XObject from any PDF page you can use
ElementBuilder.CreateFrom(page).