0

I am developing a web application using JavaScript. in a certain case i want to extract the contents inside a div element and paste it to the pdf file when i click the link "download to pdf".

I received some answers regarding this by using jsPDF lib, but is there any other way without using jsPDF? jsPDF is not supporting such things

    <div id="panel">
      //some codes 
      <a href=javascript:downloadPDF();>Download to PDF</a>
    </div>

    <script>
     function downloadPDF()
     {
      what to write here to convert to PDF
     }
    </script>
4

2 回答 2

0

您可以使用 jsPDF .jsPDF 是一个开源库,仅使用 Javascript 即可生成 PDF 文档。

http://jspdf.com/

https://code.google.com/p/jspdf/

于 2013-03-05T12:16:44.257 回答
0

可以做到,但不是10行练习。

最兼容的方法是获取要放入 PDF 的内容,将其发送到服务器,然后使用服务器端几个好的库中的任何一个来生成 PDF(在 Java 中,一个选项是iText,在 .网络上有它的优秀端口,iTextSharp还有一个 PHP 模块用于执行 PDF)。

有一个名为jspdf的 JavaScript 库,可用于在 JavaScript 中生成 PDF,无论是通过 NodeJS 或类似的服务器端,还是data:在某些浏览器上生成 URI。

于 2013-03-05T12:16:58.350 回答