将网页转换为 pdf 的 javascript 库

将网页转换为 pdf 的 javascript 库

问题描述:

有没有可以将网页转换为PDF文档的客户端库?我使用过 jspdf,但生成的 pdf 没有保留格式化的 html(比如标签在 PDF 中应该是粗体).

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

非常简单,如果您的页面没有任何敏感数据
就这样做:

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>


下载这个工具.

您可以在任何事件上调用它,例如:

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



欲了解更多信息
http://snapshotmedia.co.uk/blog/jspdf
http://itextpdf.com/
http://github.com/MrRio/jsPDF