[英]Is there any way to export the html page's data into PDF?
I have an html page which contains multiple selectboxes, labels, input fields and checkboxes. 我有一个html页面,其中包含多个选择框,标签,输入字段和复选框。
I want to export entire html page into PDF. 我想将整个HTML页面导出为PDF。 is there any way I can do so?
有什么办法可以做到吗? Any
javascript
or library for exporting HTML into PDF
? 是否有
library for exporting HTML into PDF
javascript
或library for exporting HTML into PDF
?
If you absolutely need to do generate your PDF using Javascript, you can use JsPDF : 如果绝对需要使用Javascript生成PDF,则可以使用JsPDF :
var doc = new jsPDF();
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addPage();
doc.text(20, 20, 'Do you like that?');
// Output as Data URI
doc.output('datauri');
But you will have to recreate your html page with the library's syntaxe. 但是您将不得不使用库的语法重新创建html页面。
If generating your document don't necessary have to be done with Javascript, a better way would be to use a php library. 如果不必使用Javascript来生成文档,则更好的方法是使用php库。
In the past I used (DomPdf)[https://github.com/dompdf/dompdf] : very powerfull. 过去我使用(DomPdf)[https://github.com/dompdf/dompdf]:非常强大。 It just take a HTML/CSS document and create a PDF version of it.
它只需要一个HTML / CSS文档并创建一个PDF版本。
If you absolutely need a non-refresh loading, you can use Ajax to generate the document. 如果您绝对需要非刷新加载,则可以使用Ajax生成文档。
尝试一下JsPDF: http ://jspdf.com/ :)问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.