Mik*_*ike 3 html pdf python-3.x
如何在Python3中将HTML转换为PDF?Xhtml2pdf 在 Python3 中不起作用,出现错误:
导入 xhtml2pdf.pisa 作为 pisa Traceback(最近一次调用):文件“”,第 1 行,在文件“/home/hound/test/python/test_env/lib/python3.4/site-packages/xhtml2pdf/ init .py ”,第 41 行,来自 xhtml2pdf.util import REPORTLAB22 文件“/home/hound/test/python/test_env/lib/python3.4/site-packages/xhtml2pdf/util.py”,第 302 行引发异常,“框不定义正确的方式” ^ SyntaxError:语法无效
到目前为止我发现的最好的是weasyprint.
从文档中:
from weasyprint import HTML
HTML('http://weasyprint.org/').write_pdf('/tmp/weasyprint-website.pdf')
它真的很容易工作。为我节省了大量时间(在我浪费时间试图让 xhtml2pdf 和其他人在 python 3 中工作但失败之后。
| 归档时间: |
|
| 查看次数: |
6740 次 |
| 最近记录: |