Ask HN: What do you use for PDF reports these days?
I am creating some entreprise software and almost every other information needs to be sent by email in pdf format. Reports, invoices, etc. I am using whtmltopdf right now, but it is far from ideal.
My idea setup would be to create some template with fixed parts, growable parts (texts that can vary in size), repeatable parts (lines in a table). And then just feed the data to have a nice pdf built.
The closest I found was using LibreOffice to convert a document to pdf (http://railsblog.kieser.net/2013/04/part-ii-creating-beautiful-reports-in.html).
It seems PDF generation should be a solved problem. Maybe, Adobe LiveCycle is doing exactly what I need, but it is not open source and I do not have $50k to find out.
What are you guys using?
62 comments
[ 5.5 ms ] story [ 114 ms ] threadI'm working on a related problem right now (end-user report design in the browser) so I'll be interested to see what other people say.
https://github.com/ariya/phantomjs/blob/master/examples/rast...
https://github.com/flyingsaucerproject/flyingsaucer
To help minimize request time, we keep Flying Saucer persisted with Nailgun -
https://github.com/martylamb/nailgun
For generating checks, IRS forms and other PDFs that involve precise formatting we use Prawn -
https://github.com/prawnpdf/prawn
We provide PDF reports generated from various stat pages on our site for NHL and college hockey scouts.
Performance is excellent, no caching required, and the implementation is seamless, just feed html directly to FS and voila, on-the-fly PDF reports.
It uses the Prince engine (http://www.princexml.com/), so it supports paging, headers, footers, page numbers etc. in addition to standard HTML+CSS3. It's great overall but quite pricey.
[1] https://github.com/speedata/publisher
[2] https://github.com/galkahana/PDF-Writer
Some other options I've played with:
- https://github.com/signintech/gopdf
- https://github.com/mstamy2/PyPDF2
- http://www.jagpdf.org/
There's a free version you can experiment with, to find out.
I wanted a local tool which I could script. Also I bought Prince years before DocRaptor existed. (That guy is in the Prince forums and he's pretty cool, and I like his product.)
I just wanted a command line tool though, and that's part of what you get from a personal license.
Håkon / Haakon being a common name, coincidentally the Norwegian crown prince is also named that. So searching for "haakon prince" has two quite different meanings.
These are the most important tricks:
Good font rendering, selectable text. Not perfect, but the best I've seen so far.Take a LibreOffice/OpenOffice document as your template and send a simple http request with the values you want to replace (with support for images and what you call 'repeatable parts'). The system will then return a link where you can pick up your generated pdf.
https://code.google.com/p/pyfpdf/
[0]: http://orgmode.org/manual/LaTeX-and-PDF-export.html#LaTeX-an...
[1]: http://orgmode.org/worg/org-contrib/
[2]: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-g...
[3]: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R...
You can run it directly on the client (or the server, if you like), which is really nice.
The PhantomJS solution became a bit painful, since there are issues with the way Qt converts HTML into PDF. I was impressed that even SVG generated with D3 faithfully was converted to PDF. But not being able to precisely control formatting was a problem.
After that I decided to try Reportlab, and it's been amazing. There is a free open source Python API version, and the commercial Report Markup Language product (RML). It's possible to mix Python and RML with a template engine (Preppy), very powerful. We opted for the commercial support, since time was a factor. RML is really baked, it's been around for over a decade. The documentation is extensive, but I still had to find a couple of things via googling. However, their commercial support is awesome.
If you don't want to spend a lot of time handcrafting documents, I recommend RML, despite the cost. It has features for page layout control, fonts, tables, styling and multipage text flow. There's even a charting library, which I didn't use yet. Also important was the ability to include existing PDF pages as backgrounds or chart inserts.
same for Business Objects, but IMHO needlessly more complicated than the former.
obviously neither are open source, and an SSRS license is worth it if your business spits out many reports.
SQL Server Express with Advanced Services ships with SSRS, is free, comes with all the tooling and generates PDFs too.
Perhaps surprisingly, if you install your ODBC drivers for your database engine (MySQL, Postgres etc) you can create a report from that data source as well so you're not tied to SQL Server as a database engine.
Typical steps: http://www.mssqltips.com/sqlservertip/2615/creating-a-ssrs-r...
And report builder: http://www.youtube.com/watch?v=Iy-bE0yXGlk
Can't beat it for $0.
same for Business Objects, but IMHO needlessly more complicated than the former