tags:

views:

1563

answers:

16

I know there are quite a lot of questions on this topic (1, 2, 3, 4, lots), but there doesn't seem to be a good comprehensive community wiki rundown of HTML to PDF engines.

Please stick to one product in each answer and edit or add comments to answers, rather than add another one if you have something to say about an engine that is already listed.

Vote for answers only if you have looked into them and they work well, so that good engines bubble to the top.

Please list:

  1. Is it open source, paid, free for non-commercial etc?
  2. What OSes and language wrappers are supported?
  3. Any special features (supports print CSS, supports it's own CSS extensions etc.)

Also, please include programmable answers only, not things that require using a GUI - this is a programming forum.

+2  A: 

DOMPDF

Open source, written in PHP. PDF rendering is currently provided either by PDFLib (http://www.pdflib.com) or by a bundled version the R&OS CPDF class written by Wayne Munro (http://www.ros.co.nz/pdf).

it had huge problems with tables. I factored out my large nested tables and it helped (before it was just consuming up to 128M of memory then dying--thats my limit on memory in php.ini) but it makes a complete mess of tables and doesn't seem to get images. The tables were just basic stuff with some border styles to add some lines at various points;

(taken from http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php)

rjmunro
I tried HTML2PDF and had loads of problems - seems css does not work well in table cells - after 2 hours of this i switched to dompdf and in half an hour i was cooking - TIP: i think their installation is missing the config file - use the 0.5 version found on google scripts
Johnny Darvall
+1  A: 

HTML2PDF and HTML2PS

PHP based free-as-in-beer (not open source). Requires Ghostscript to generate the PDF and has several other dependencies.

It rendered some of the images (all the images are Google Chart URLs) and the table formatting was much better but it seemed to have some complexity problem I haven't figured out yet and kept dying with unknown node_type() errors.

(comment taken from http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php)

rjmunro
Does the very vary basics - but a nightmare for anything slightly complex - use dompdf
Johnny Darvall
+1  A: 

Htmldoc

Commercial product with open source limited version. Available for Windows, Mac OS, Linux and Solaris.

Open source version included in Debian and probably other distros.

This seems to work fine on basic HTML but has almost no support for CSS whatsoever so you have to do everything in HTML (From http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php)

rjmunro
The open source version isn't limited at all. It's just that you have to compile it yourself. The commercial product consists of: 1) binaries are readily compiled for your platform and 2) you are entitled to get some sort of support. (The author of HTMLDOC is Mike Sweet, who is also the principal developer of CUPS.) -- Yes, CSS support is currently in development.
pipitas
+9  A: 

WKhtmlToPDF

Open source Webkit QT4 based solution.

Great product... Header and footer features are really fantastic and its use of WebKit really makes this approach rather innovative. Its actively under development and the support is good.

Only limitations I have found is with some fairly advanced javascript layout scearioes (i.e. http://www.simile-widgets.org/timeline/ trying to catpute the timeline - but this is hardly a common scenario).

Besides that just keep in mind that what ever limitations WebKit has this has too, but that is also a plus as well (as WebKit can do a lot).

The only place WebKit struggles a little atm is with some page breaking (i.e. sometimes it will break on an image or through text). But as WebKit's support for page-break-before, page-break-after, etc becomes better WKhtmlToPDF will be able to take advantage of the improvements.

rjmunro
+1  A: 

Firefox CommandLinePrint2

Open source. Firefox add on that allows you to generate PDFs from the command line using the currently installed firefox. Runs wherever firefox does, but some features are limited on some platforms. Requires firefox to be installed, and firefox will briefly open a window with the page before saving the PDF and closing. This means that on Linux you need to have an X server running, and the process calling firefox will need permissions to open a window on the X server.

rjmunro
A: 

PDF Duo .NET

The component can be used in any ASP.NET languages VB.Net, C# for converting HTML to PDF.

  1. Commercial
  2. ASP.NET all Supports CSS,
  3. Doesn't use any additional components. For Source code ask by email.
Constantine
A: 

Pdfcrowd

Provides online HTML to PDF API. Can be used on any platform that supports HTTP. API libraries for Python, Ruby, .NET, Java, and PHP are available.

It is a webkit based solution. It can be a good fit for applications that run on shared hosting or if you simply don't want to bother with installing anything locally.

It is in a free public beta now.

A: 

WKPDF

Mac OS only Apple webkit based command line tool.

Similar to WKhtmlToPDF but uses Mac OS specific APIs, so not portable to other platforms.

rjmunro
A: 

Prince XML

  1. Closed source. Free for non-commercial use.
  2. Cross platform. Language bindings for Java, Python, Perl, PHP, ASP, ColdFusion and ActiveX / COM / Visual Basic.
  3. Really great CSS2-3 support (footnotes, cross-referencing, generated content, CSS columns, page headers and footers, ...). Great typography, including TeX-style full-paragraph justification. WOFF/@font-face support. Supports both HTML and XML. Add bookmarks to the PDF for h* elements.

(You noticed I kinda like it?)

Ms2ger
It's quite expensive - $495 for a single user desktop version and $3800 for a server.
rjmunro
A: 

HTML to LaTeX

Written in Java. Converts HTML to LaTeX format which LaTeX can then turn into PDF.

Supports limited set of CSS, but you can embed LaTeX commands in special comments which will give a lot of flexibility, although it will probably be hard to use.

(I haven't tried it)

rjmunro
+1  A: 

ABCpdf

Uses the IE rendering engine (MSHTML) to calculate PDF layout (see support page).

Commercial software, but free licenses are available if you link to their site.

I have no first-hand progamming experience (but worked in a project that used it), so please edit if essential information is missing

devio
A: 

PDF Reactor

  1. Commercial, license is around 3000 USD
  2. Supports for Mac, Linux, Windows
  3. Java based but wrapper for Perl.
  4. Supports CSS, PDF/A, SVG
  5. Command line is available but can't handle multiple files to merge in single pdf
  6. Can be integrated in web service
ppant
A: 

TCPDF

php Lib, so OS independent

Digital signatures, encryption,

no external libraries are required for the basic functions;

UTF-8 Unicode and Right-To-Left languages;

TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts; Font subsetting;

methods to publish some XHTML + CSS code, Javascript and Forms;

native support for JPEG, PNG and SVG images;

1D and 2D barcodes: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index - Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS, QR-Code, PDF417;

automatic page header and footer management;

bookmarks and table of content;

automatic page break, line break and text alignments including justification;

Since when is TCPDF an **HTML to PDF** converter? It seems to have [only simple, primitive HTML support](http://www.tecnick.com/pagefiles/tcpdf/doc/com-tecnick-tcpdf/TCPDF.html#methodwriteHTML).
Charles
+1  A: 

mPDF

Opensource (GPL),

written in PHP,

supports UTF-8,

renders even very bad coded HTML (tested myself :) ),

very good tables support

it even renders form buttons as vector graphics (crazy!)

bartek
resulting PDFs look fine. Although I haven't pushed the limits of its CSS rendering, it does what I need it to for the moment. The issue I'm having is that the final files are about 2.5 times the size of those that come from princeXML
bibby
A: 

ExpertPDF

Commercial, .NET framework. Uses the IE rendering engine, so it supports anything IE support (html / css).

Flores
A: 

XHTML2PDF

Apache licensed pure Python solution.

Holtwick