问题
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).
回答1:
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
来源:https://stackoverflow.com/questions/13491657/javascript-library-to-convert-web-page-to-pdf