Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What HTML to PDF libraries handle javascript?

I'm trying to figure out how to generate a PDF from HTML that contains charts generated with the flot javascript library. Dompdf was my original conversion library but after adding flot charts it fails miserably. I've looked around SO (particularly at https://stackoverflow.com/questions/3178448/list-of-html-to-pdf-converters) and googled for a while but can't seem to find any that explicitly provide javascript support. I'm working in PHP. I saw someone mention in that post that they had used php-wkhtmltox successfully in all cases but a chart generated by a different javascript library. Is that my only chance? I could possibly pay up to a couple hundred dollars if there is a commercial option available.

If this is something that really isn't possible with current libraries, what exactly is the challenge that makes it so much harder to convert html generated by javascript vs. normal html?

Thanks

like image 695
Dave Novelli Avatar asked Feb 01 '11 04:02

Dave Novelli


People also ask

How do I export my HTML page as PDF using JavaScript?

Generate PDF using JavaScriptSpecify the content in text() method of jsPDF object. Use the addPage() method to add new page to PDF. Use the save() method to generate and download PDF file.

Can JavaScript generate PDF?

We can start by introducing jsPDF, jsPDF is an open-source library for generating pdf using only JavaScript. It simply creates a pdf page and applies your formatting to the page. Note that we can change the presentation of the data inside the downloaded PDF file by editing the orientation and format.


1 Answers

You can use wkhtmltopdf

Just extract it onto your server, run the command (check out the manual here).

Thank you.

like image 149
Wazy Avatar answered Sep 24 '22 10:09

Wazy