2

This is a crucial question to many:

Searching the web, I have found several command line tools that allow you to convert a HTML-document to a PDF-document, however they all seem to use their own, and rather incomplete rendering engine, resulting in poor quality

How can you print the rendered output of a modern web-browser to pdf, (and/or svg) whilst retaining as much vector graphics as possible?

There is a solution called: webkit-pdf (which renders everything to bitmap graphics)

I am looking for options, alternatives, suggestions perhaps even a printer-driver or webservices?

Update: So far I found the following

Links:

Thanks

2
  • You may want PDFCreator (printer-driver). I just printed a HTML page with VML vector graph embedded from IE browser, a SVG graph from Firefox browser, PDFCreator retains these vector stuffs. Sep 26, 2012 at 9:12
  • @LiuYan刘研 this should probably be an answer. please elaborate. The browsers restrict and reformat their printed output. there are some css-media tricks to include background images, but even then... Sep 26, 2012 at 13:30

2 Answers 2

1

Rendered output is, by definition, a bitmap image.

The vector objects from which that bitmap image was constructed are not accessible from that rendered image.

You would have to return to the original HTML and CSS (etc) and use that original material to produce a new vector-based representation using a new parallel implementation of the layout algorithms that were used to produce the bitmap.


Chrome's "Print as PDF" function seems to preserve the vector nature of fonts and some other parts of the final image - you can zoom in indefinitely, as shown below, without the obvious pixellation you get from bitmap images in PDFs.

enter image description here

5
  • Internal browser print functions are not what I am looking for. For rendering see ( en.wikipedia.org/wiki/Render ). Web browser engine: software that takes information and displays the formatted content on the screen Sep 26, 2012 at 9:10
  • @Lo: It may help if you edit your question to specify which "options, alternatives and suggestions" you have already ruled out (reasons might also be useful to potential answerers) Sep 26, 2012 at 9:16
  • "How can you print the rendered output of a modern web-browser to pdf" ? Change the way your question is worded if this is not the answer you require.
    – HaydnWVN
    Sep 26, 2012 at 9:16
  • @HaydnWVN, RedGrittyBrick please see fit to edit however you would like to improve the question and content. Feel free to make this into a community wiki. Sep 26, 2012 at 13:33
  • I see no benefit to wiki'ing this. It's your question for your problem. How do we know what you're trying to achieve? RedGrittyBrick already answered your original question!
    – HaydnWVN
    Sep 26, 2012 at 14:15
1

You may want PDFCreator (printer-driver), it's an open source project hosted at sourceforge.net.

I just printed a HTML page with VML (MSDN) vector graph embedded from IE browser, a SVG graph from Firefox browser, to PDFCreator, and PDFCreator retains these vector data.

If you don't care about the difference of rendered results between screen and printer device (as you mentioned in comment about the media attribute of style tag), then PDFCreator is an answer.


Samples

Original rendered output of browser to screen device (SVG logo displayed in Firefox 15.0.1)

SVG graph displayed in Firefox

Print to PDFCreator printer (rendered to printer device)

View PDF in zoom level 100%

PDF zoom 100%

View PDF in zoom level 150% (lossless zoom)

PDF zoom 150%


More samples based on VML vector graph

yes, it's just rotated text, but it IS VML vector graph

HTML code of the VML vector graph

<html xmlns:v='urn:schemas-microsoft-com:vml'>
    <head>
        <style>v\: * { behavior:url(#default#VML); display:inline-block }</style>
    </head>

    <body>
        <v:line from="0,100" to="200,0" style="float:left">
            <v:path textpathok="True"/>
            <v:textpath on="True" string="SuperUser.com"/>
        </v:line>
        <h1>Q479701</h1>
        <p>
            PDFCreator retains vector graph
        </p>
    </body>
</html>
1
  • this is great. The problem then is how to print a complete website as is? (without applying those crippling printer-stylesheets or whatever the browser do...). Is this possible in the IE? Sep 28, 2012 at 5:46

Not the answer you're looking for? Browse other questions tagged .