Is it possible to save HTML page as PDF using JavaScript or jquery?

ram picture ram · Aug 1, 2011 · Viewed 245.6k times · Source

Is it possible to save HTML page as PDF using JavaScript or jquery?

In Detail:

I generated one HTML Page which contains a table . It has one button 'save as PDF'. If user clicks that button then that HTML page has to convert as PDF file.

Is it possible using JavaScript or jquery?

Answer

Raynos picture Raynos · Aug 1, 2011

Yes, Use jspdf To create a pdf file.

You can then turn it into a data URI and inject a download link into the DOM

You will however need to write the HTML to pdf conversion yourself.

Just use printer friendly versions of your page and let the user choose how he wants to print the page.

Edit: Apparently it has minimal support

So the answer is write your own PDF writer or get a existing PDF writer to do it for you (on the server).