简体   繁体   English

生成打开页面的PDF文件-Spring

[英]Generating PDF file of open page - Spring

One of my html templates, has several charts and information about a user. 我的html模板之一,有一些图表和有关用户的信息。 What I want to be able to do, is on button click to generate PDF of that page. 我想要做的是,单击按钮即可生成该页面的PDF。 So, the same exact view,design and data that it has, in a PDF. 因此,PDF中具有相同的精确视图,设计和数据。 Is there a way to do this in Spring ? 春天有办法吗? What libraries are best ? 什么图书馆最好?

I have seen some examples, but they create a PDF out of data they give dynamically. 我看到了一些示例,但是它们是根据动态提供的数据创建PDF的。 And I just want to know if it's possible to generate pdf of the open page as it is. 我只想知道是否可以按原样生成打开页面的pdf。 How do I do this ? 我该怎么做呢 ?

Thank you :) 谢谢 :)

You can take a screenshot with html2canvas and set the image to a canvas. 您可以使用html2canvas截屏并将图像设置为画布。

Then convert canvas to pdf using jsPDF 然后使用jsPDF将canvas转换为pdf

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

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