简体   繁体   English

Python中的HTML页面为PDF?

[英]HTML page to PDF in Python?

Is there a library available to convert a HTML page (text, images, layout elements etc. ) to a PDF file. 是否有可用于将HTML页面(文本,图像,布局元素等)转换为PDF文件的库。

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. 我有一个HTML页面,上面有数字,文字和数字等表格,我希望我的客户能够以PDF格式下载。 How do I do this with Python? 我如何用Python做到这一点?

Not too familiar with python, and prince is nice if you are willing to shell out the cash. 不太熟悉python,如果你愿意把现金掏空,王子会很好。 There is this http://github.com/antialize/wkhtmltopdf that uses webkit. 有这个http://github.com/antialize/wkhtmltopdf使用webkit。 It is a simple command line utility that you can call and it will honor html+css. 它是一个简单的命令行实用程序,您可以调用它,它将尊重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. 它有一个红宝石的宝石http://github.com/jdpace/PDFKit ,不是它可以帮助你,但可能会给你一些想法。

那么,有reportlabhtml2pdf模块,但为了获得最佳结果,我可能会尝试外部调用Princehttp://www.princexml.com/doc/6.0/python/ )。

Have you heard of xhtml2pdf/pisa? 你听说过xhtml2pdf / pisa吗?

It has the ability to work as a python module or as a separate command line utility. 它可以作为python模块或单独的命令行实用程序工作。

You can use the documentation here to get started: http://www.xhtml2pdf.com/doc/pisa-en.html 您可以使用此处的文档开始: http//www.xhtml2pdf.com/doc/pisa-en.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM