Saving pdf on server side with jsPDF

独自空忆成欢 提交于 2019-12-08 06:42:30

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.

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.

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.

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