I tweeted about this earlier today:
http://twitter.com/seacreature/status/16257687342
That post is incredibly unreasonable, since it does not show a
comparison to Prawn for table output.
In general, I feel like html2pdf is a great idea when you actually want
html to pdf.
But for generalized document generation and typesetting: I think it'd
be easy to generate a ton of PDFs that any html2pdf tool would choke all
over itself on (except maybe Prince).
I'm going to wait until I'm no longer irritated by that post and write
up my thoughts on this. It's mainly that this isn't the first time I've
seen someone announce how some HTML2PDF tool was soooo much better than
Prawn, but that comparison is based on a very narrow subset of what
Prawn is useful for.
(For what it's worth though, I don't have my doubts that html2pdf tools
give acceptable output for much less effort in certain situations)
-greg
On 6/15/10 9:43 PM, jonsgreen wrote:
> I was wondering whether you guys had heard about this:
> http://thinkrelevance.com/blog/2010/06/15/rethinking-pdf-creation-in-ruby.html
In general, I feel like html2pdf is a great idea when you actually want
html to pdf.
> Depending how the Prawn tables end up, maybe pages with titles, text,
> and tables will be easier in pdfkit. Especially pages using Rails-like
> layouts
Yeah, in the context of Rails, I can see a lot of 1 page PDFs benefiting
from html2pdf tools.
But I wonder how it handles pagination, if at all. If anyone feels the
urge, please try it out and post some examples back here.
Unfortunately, while the article had links to some PDFs, there wasn't
much code to bite into. If we had a bit of that going on, it would be
easier for me to chill out :)
I'd really love to make up a "When to use Prawn vs. When to use HTML 2
PDF" guide. Could be helpful to our users.
-greg
I haven't tried PDFKit, and have neither the time nor the urge now,
but I have used Prince XML, in conjunction with Princely, so I can
comment there.
Pagination worked fine for many purposes. The project with which I
used Prince included tables that extended onto new pages. They flowed
fine from page to page. The page-break CSS elements work. Prince
enables the inclusion of portrait and landscape orientation in the
same document.
However, I don't think it would be possible to do conditional page
breaking, as is possible in Prawn via grouping, or as we are aiming
for with the new delayed rendering (eg: if only one row of the table
fits on this page, move it to the next). And multi-column documents
where text flows from left column to right, and then on to the next
page, aren't achievable in HTML unless there is something I don't know
about (I haven't looked into the HTML specification for dealing with a
paginated environment).
The big win with Prince (or perhaps PDFKit) is when you need to
provide people with the ability to download a PDF version, or print a
nice version, of a page that you are already generating as XHTML +
CSS. The money saved by only needing to hire someone to write HTML +
CSS, rather than someone to write HTML + CSS and someone else to
generate the Prawn or whatever else that corresponds to the HTML + CSS
can easily surpass the $3,800 fee (which is a one-time fee, not an
annual license) for Prince XML. Especially if the appearance of those
documents is changed frequently or there are many different document
layouts. Plus, there is less room for the PDF output to stray from
what people see in the browser, which can be important to a company.
Prince XML + Princely was amazingly true to the original HTML + CSS.
The only adjustment I needed to make that was due to Prince was to
reduce the font size declared in body because printed output didn't
need as large a font as on-screen. Princely made it easy to do this
with the application of an additional stylesheet to override the
screen style.
But for the project I'm doing now, the PDF output I need cannot be
rendered in HTML, so no HTML to PDF converter would work. Prawn does.
-Daniel