views:

113

answers:

4

Is there a library available to convert a HTML page (text, images, layout elements etc. ) to a PDF file.

I have an HTML page with figures, text and tables with numbers etc. which I want my clients to be able to download as PDF. How do I do this with Python?

+1  A: 

Well, there are the reportlab and html2pdf modules, but for best results I'd probably try calling Prince externally (http://www.princexml.com/doc/6.0/python/) .

chryss
+1  A: 

Not too familiar with python, and prince is nice if you are willing to shell out the cash. There is this http://github.com/antialize/wkhtmltopdf that uses webkit. It is a simple command line utility that you can call and it will honor html+css. As far as I know, it is the only free tool to do so well. There is a ruby gem for it http://github.com/jdpace/PDFKit, not that it helps you but might give you some ideas.

Geoff Lanotte
A: 

Check out pdfcrowd and their online conversion API. They have a client library for python which makes using the API quite easy.

A: 

Have you heard of xhtml2pdf/pisa?

It has the ability to work as a python module or as a separate command line utility.

You can use the documentation here to get started: http://www.xhtml2pdf.com/doc/pisa-en.html

Bryce