简体   繁体   中英

Saving pdf on server side with jsPDF

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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