Is it possible to save the HTML page in PDF format using JavaScript or jquery?

advertisements

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?


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.

However this is very silly. Why do you want to turn a HTML page to pdf?

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).