开发者

HTML page to PDF in Python?

开发者 https://www.devze.com 2023-01-06 17:40 出处:网络
Is there a library available to convert a HTML p开发者_如何学Pythonage (text, images, layout elements etc. ) to a PDF file.

Is there a library available to convert a HTML p开发者_如何学Pythonage (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?


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.


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/) .


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

0

精彩评论

暂无评论...
验证码 换一张
取 消