Convert HTML to PDF with links

痞子三分冷 提交于 2020-01-25 04:25:27

问题


Is there a node.js module or a javascript library that can convert HTML/Page into PDF with selectable texts and working links? I've tried Phantomjs. But since its the only screenshot the page and convert it to pdf, texts are not selectable and links are not working. Also tried jsPDF but links are not working either. Hope you guys can share some of your experience in dealing the same problem.

Your response is greatly appreciated.


回答1:


You can parse the HTML body with htmlparser. The complete html will be properly converted to JSON.

Depending upon the keys, you can then write it to a PDF using pdfkit.

This is very general solution. If you give us an insight as to what type of HTML you want to get into a PDF, maybe then we would be able to help with some specific code or logic.




回答2:


Try http://www.cloudformatter.com/css2pdf.

Their links demo at http://www.cloudformatter.com/CSS2Pdf.Demos.Hyperlinks shows external links and internal links within the generated PDF.



来源:https://stackoverflow.com/questions/32109711/convert-html-to-pdf-with-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!