Mahesh Shitole
Mahesh Shitole

Reputation: 912

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. Is there any alternative ?

Upvotes: 2

Views: 1641

Answers (2)

Mahesh Shitole
Mahesh Shitole

Reputation: 912

I did few changes in html which results pisa.createPDF works fast for me. I am using html of almost 2 MB, contains single table with almost more than 10,000 rows. 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.

Upvotes: 1

NorthCat
NorthCat

Reputation: 9937

You can try pdfkit:

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

Also see this question which describes solutions using PyQt.

Upvotes: 0

Related Questions