简体   繁体   English

如何在Vuejs中从HTML和CSS生成pdf?

[英]How to generate pdf from html and css in Vuejs?

I'm working on a tool "Resume Builder" using Vuejs. 我正在使用Vuejs开发工具“ Resume Builder”。 Is there any bettter way to generate pdf ( of resume ) from html with css . 有没有更好的方法可以用css从html生成pdf(简历)。 I have used jsPdf Library but not getting desired outcomes. 我使用了jsPdf库,但没有得到预期的结果。 I want to keep html "a" tag clickable in generated pdf. 我想在生成的pdf中保留可点击的html“ a”标记。 I have also tried html2canvas.js but in that "a" tag is not clickable due to image in pdf. 我也尝试了html2canvas.js,但是由于pdf中的图像,“ a”标签不可点击。 jsPdf is generating pdf but not applying css. jsPdf正在生成pdf,但未应用CSS。

I recommend you to investigate a bit different approach for generating PDF from HTML just because all the client-side libraries for HTML to PDF generation have lots of problems when generating really complex documents with lots of formatting etc. 我建议您研究一下从HTML生成PDF的另一种方法,因为在生成具有很多格式等的非常复杂的文档时,所有用于HTML到PDF生成的客户端库都存在很多问题。

The alternative way is to perform the PDF generation itself on the server-side. 另一种方法是在服务器端本身执行PDF生成。 For example, you could make use of Headless Chrome managed by your backend for turning any HTML into PDF. 例如,您可以利用后端管理的Headless Chrome将任何HTML转换为PDF。

We used a very similar approach to implement pdf generation for this free resume builder service. 我们使用了一种非常类似的方法来为此免费的简历生成服务实现pdf生成。 The only downside we faced was that different browsers like Firefox or IE might occasionally display an HTML document a bit different than it's printed out as PDF bu Chrome. 我们面临的唯一缺点是,诸如Firefox或IE之类的不同浏览器有时可能会显示HTML文档,该文档与以PDF bu Chrome形式打印的文档有所不同。 Good luck! 祝好运!

You might want to give Pdf Make a try. 您可能想尝试一下Pdf。

PDF Make on Github 在Github上制作PDF

It has support for styling and links. 它支持样式和链接。 But you have to do most of the styling yourself. 但是您必须自己进行大部分样式设计。

I found Kendo UI is the best api for pdf from DOM. 我发现Kendo UI是DOM中pdf的最佳API。

https://docs.telerik.com/kendo-ui/framework/drawing/drawing-dom https://docs.telerik.com/kendo-ui/framework/drawing/drawing-dom

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM