简体   繁体   English

pisa.CreatePDF 挂起巨大的 html 文件

[英]pisa.CreatePDF hangs with huge html file

I am generating pdf using html template with python pisa.CreatePDF API, It works well with small html, but in case of huge html it takes lot of time.我正在使用带有 python pisa.CreatePDF API 的 html 模板生成 pdf,它适用于小 html,但在巨大的 html 的情况下需要很多时间。 Is there any alternative ?有没有其他选择?

I did few changes in html which results pisa.createPDF works fast for me.我在 html 中做了一些更改,结果 pisa.createPDF 对我来说工作得很快。 I am using html of almost 2 MB , contains single table with almost more than 10,000 rows .我正在使用将近2 MB 的html,包含几乎超过10,000 行的单个表。 So I break them into multiple tables and tried again.所以我把它们分成多个表,然后再试一次。 Its surprised me, initially with single table it took almost 40 minutes (2590 seconds) to generate PDF and with multiple tables it has taken only 80 Seconds .它让我感到惊讶,最初使用单个表生成PDF需要将近40 分钟(2590 秒) ,而使用多个表只需要80 秒

You can try pdfkit :你可以试试pdfkit

import pdfkit
pdfkit.from_file('test.html', 'out.pdf')

Also see this question which describes solutions using PyQt.另请参阅此问题该问题描述了使用 PyQt 的解决方案。

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

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