Is there any client-side library that can convert a web page to a PDF document? I have used jspdf but the generated pdf does not retain the formatted html (like tags should be boldface in the PDF).
Generate PDF using JavaScript The following example shows how to use the jsPDF library to generate PDF file using JavaScript. Specify 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.
jsPDF. 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.
Very simple if your page is not having any sensitive data
Just Do this:
<a href="http://pdfcrowd.com/url_to_pdf/">Save this page to a PDF</a>
Download this tool.
And you can invoke it on any event like:
<script>
function generatePDF(){}
var conv = new ActiveXObject("pdfServMachine.converter");
conv.convert("http://www.google.com", "c:\\google.pdf", false);
WScript.Echo("finished conversion");
}
</script>
<body onload="generatePDF()">
</body>
var conv = new ActiveXObject("pdfServMachine.converter");
conv.convert("http://www.google.com", "c:\\google.pdf", false);
WScript.Echo("finished conversion");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With