Saving pdf on server side with jsPDF

雨燕双飞 提交于 2019-12-23 01:58:20

问题


I have an application that generates a HTML page with data which the user can edit. At the end I generate a .pdf file with jsPDF. Is there any way that I can save this generated .pdf on my server-side database?

I'm using PrimeFaces.

Thanks in advance


回答1:


Thanks all for the help! I've found my solution:

Once the user presses on the button to generate the .pdf, I'll save all the data he filled on the database, just the data.

When the user wants to see the pdf he generated back, I'll generate a new one with the data collected on his first submit.

Thank you all for the answers, they were helpful.




回答2:


Updating my solution for other users:

I found the .output('datauristring') method of the jsPDF which returns me a BASE64 String.

Then the String is sent via JSON to my backed bean and converted as my will.




回答3:


I suggest to use wkhtmltopdf.

It is a open source cross platform command line tool to generate pdf files from html content.

So to your requirement what you can do is, you need to send the html content to the server and save this content into a html file.

Once you saved html content into html you can call wkhtmltopdf like you execute MS-DOS commands in java.

Example: new ProcessBuilder("wkhtmltopdf.exe", htmlFilePath, pdfFilePath);

Once pdf file is generated you can read and store into database.



来源:https://stackoverflow.com/questions/42004002/saving-pdf-on-server-side-with-jspdf

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