Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript library to convert web page to pdf [closed]

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

like image 775
Sudipta Roy Avatar asked Nov 21 '12 10:11

Sudipta Roy


People also ask

How do I make a PDF of a Web page using JavaScript?

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.

Can JavaScript generate PDF?

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.


1 Answers

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>


OR

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");


OR
For more information
http://snapshotmedia.co.uk/blog/jspdf
http://itextpdf.com/
http://github.com/MrRio/jsPDF
like image 175
Amol M Kulkarni Avatar answered Oct 13 '22 17:10

Amol M Kulkarni