How does google make make those awesome PDF reports in Analytics and when you print a Google Doc etc? [closed]

StackOverflow https://stackoverflow.com/questions/47709

Question

When you print from Google Docs (using the "print" link, not File/Print) you end up printing a nicely formated PDF file instead of relying on the print engine of the browser. Same is true for some of the reports in Google Analytics . . . the printed reports as PDF's are beautiful. How do they do that? I can't imagine they use something like Adobe Acrobat to facilitate it but maybe they do. I've seen some expensive HTML to PDF converters online from time to time but have never tired it. Any thoughts?

Was it helpful?

Solution

If you are specifically looking at how Google does it. If you look at the PDF Properties page, they use Prince 6.0 (see princexml.com)

There are lots of other PDF generators out there. I've had great success with PDFlib for tricky jobs.

alt text

OTHER TIPS

iTextSharp and iText are opensource and free PDF generation libraries for .NET and Java respectively.

I've used them to generate report PDF's before and was quite happy with the results.

http://itextsharp.sourceforge.net/

http://www.lowagie.com/iText/

Great free alternative to PrinceXML: wkhtmltopdf . There are plenty of wrapper libraries for various languages - but I've only used Ruby ones. However the product itseld is on par with PrinceXML IMHO.

I have had success with pd4ml. It has a tag library, so you can turn any existing HTML into PDF by

<pd4ml:transform>
<!-- Your HTML is here -->

<c:import url="/page.html" />
</pd4ml:transform>

Well, I doubt it's as easy as generating HTML . . . I mean, first of all, PDF is not a human readable format and it's not plain text (like SVG). In fact, I would compare a SVG file to a PDF file in that with both you have precise control over the layout on a printed page. But SVG is different in that it's XML (and also in that it's not supported completely in the browser . . . still looking into SVG too). Come to think of it, SVG should probably will be my next question.

I know Google doesn't use .NET and I doubt they use Java so there must be some other libraries they use for generating the PDF files. More importantly, how do they create the PDF's without having to rewrite everything as a PDF instead of as HTML? I mean, there has to be some shared code for between when they generate the HTML view as opposed to the PDF view. Come to think of it, maybe the PDF view and the HTML view are completely separate and they just have two views and hence why the MVC development style seems to be the way to go.

Rendering a PDF is hard, complex problem. However generating them, is not. Simply make up some entities, and generate. It's about same problem domain as generating HTML for webpage vs. displaying (rendering) it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top