5

I am looking for a C/C++ library to convert HTML (Actually XHTML + CSS) documents to PDF.

It is for commercial use and source would be nice but not essential.

Anybody have any recommendations or experience doing this?

UPDATE: To clarify, I am targeting the Windows platform only. I am developing with Borland C++ Builder 2006, but the library does not have to be a VCL component.

Many thanks in advance.

Steve.

QAZ
  • 4,870
  • 6
  • 36
  • 50

7 Answers7

4

To do that I have successfully used wkhtmltopdf. Uses webkit and can be called from command line or as a static library. It's great and simply to use.

wkhtmltopdf website

OpensSource (LGPL) and free!

Hope it can help

Mathlight
  • 6,436
  • 17
  • 62
  • 107
Albertino80
  • 1,063
  • 7
  • 21
  • This is the best answer by far. wkHTMLtoPDF is much more mature than VisPDF or PDFDoc. The accepted answer doesn't even use C++ but C#.. note: wkHTMLtoPDF link is now at http://wkhtmltopdf.org/ – That Realty Programmer Guy May 08 '15 at 14:28
1

Wouuld CLI applications do? If memory fails me not, GNU Ghostscript had utilities html2ps and ps2pdf. Source should be available too.

Vilx-
  • 104,512
  • 87
  • 279
  • 422
0

I tried HotPDF library, it is easy to use and good enough.

Sergio
  • 1
  • Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Jack Dec 18 '12 at 22:39
0

This is probably overkill, but WebKit for rendering, with Cairo for the backend could do it. WebKit is a pretty big library, though.

If you are looking for something pre-made, I found wkhtmltopdf after some quick searching. It uses WebKit and Qt for rendering, which is and even larger combination of libraries.

Jeff M
  • 700
  • 3
  • 10
0

Just to bump this, I have evaluated both VisPDF and PDFDoc Scout and will probably go with PDFDoc Scout as it can format HTML input.

Thanks for everybody else's input.

QAZ
  • 4,870
  • 6
  • 36
  • 50
-1

CutePDF is a free PDF writer that works as a virtual printer. I guess you could use this in conjunction with anything that could render your HTML.

SmacL
  • 22,555
  • 12
  • 95
  • 149
-2

Have a look at PrinceXML.

It's definately the best HTML/CSS to PDF converter out there, although it's not free (But hey, your programming is not free either, so if it saves you 10 hours of work, you're home free.)

Oh yeah, did i mention that this is the first (and probably only) HTML2PDF solution that does full ACID2!?!?!

http://princexml.com/samples/

SchizoDuckie
  • 9,353
  • 6
  • 33
  • 40