News for hackers. Stuff that matters.

Ask YC: Open source HTML to PDF

Any suggestions for a solution to producing PDF's automatically from dynamic output?

Something preferably able to produce output similar to manually "Printing to PDF" from a browser window...

( 8 comments | 4 points | on HN )
Re:Ask YC: Open source HTML to PDF by callahad on Friday March 20, 2009 @11:46AM (#525058)
Depending on your use case, check out [Sphinx][1], which is used for the new [Python documentation][2]. Basically, you write your documentation in [reStructuredText][3] which Sphinx then renders into HTML or LaTeX. The LaTeX output can be trivially turned into a PDF and [looks great][4].

[1]: http://sphinx.pocoo.org/

[2]: http://docs.python.org/

[3]: http://docutils.sourceforge.net/rst.html

[4]: http://sphinx.pocoo.org/sphinx.pdf

Re:Ask YC: Open source HTML to PDF by crnixon on Friday March 20, 2009 @11:16AM (#525007)
Flying Saucer (https://xhtmlrenderer.dev.java.net/) is a pretty badass solution for what you want. It's a Java library, but you can use it in Ruby or any other language that runs on the JVM pretty easily.
Re:Ask YC: Open source HTML to PDF by matticakes on Friday March 20, 2009 @11:32AM (#525030)
This is impressive, thank you. Gotta love well-formed XHTML.
Re:Ask YC: Open source HTML to PDF by bcater on Friday March 20, 2009 @12:07PM (#525075)
I'm not sure what your use case is, but we've had much better luck with generating LaTeX code that we compile to PDF (the trivial step) than with doing HTML to PDF.
Re:Ask YC: Open source HTML to PDF by matticakes on Friday March 20, 2009 @12:30PM (#525118)
My use case is basically taking an automated web-based daily newsletter (html, css, images) and generating a PDF
Re:Ask YC: Open source HTML to PDF by kbhangui on Friday March 20, 2009 @03:56PM (#525479)
http://www.xhtml2pdf.com/

Perhaps this python library?

Re:Ask YC: Open source HTML to PDF by noodle on Friday March 20, 2009 @11:17AM (#525013)
there are a good handful of options. what language would you prefer? or do you want some separate system?
Re:Ask YC: Open source HTML to PDF by matticakes on Friday March 20, 2009 @11:31AM (#525029)
It doesn't necessarily need to be built into the language that the content is being produced in. I came across HTMLDOC, for example. I suppose anything that can run on linux.