Skip to content
Advertisement

What is the fastest way to convert html to pdf using JS or PHP?

I have a long table for about ~100.000 rows which is generated dynamically (technically it can be divs).
It’s needed to export this html data into pdf.

I have tried to use html2pdf.js. But when it is over 5000 rows it begins to work very slow and exported pdf has huge size. I think it is due to saving html as image and then inserting it into document.

Have tried html2pdf.php Also works slow from over 500 rows already has troubles, but document has very good size.

Have tried html-pdf with node js. Works much faster then previous 2, but there is one limitation. Node js script is on server and when there more then one client, performance is distributed between all client and performance decreases dramatically.

I am in search of library which will convert very long html table into pdf document for acceptable amount of time.

My needs can be described as:

1) The script can run in browser (Javascript) an should be fast enough in order not to make user wait for ages.

2) The script can run on server using PHP/Node js, but here should be considered that at the same time several users can request pdf.

3) May be there are some other solutions for examples on Java or Python which will run on Linux server that could be easily triggered from browser?

Options 1 or 2 are the most desirable.

Thanks!

Advertisement

Answer

One of the comments (which is deleted for some reason) suggested me to try AutoTable – Table plugin for jsPDF.
Thank you!
This plugin for js library html2pdf does an amazing job! Works with the speed of light.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement