Reputation: 11
I have project based on spring boot. which create salary slip for employee dynamically, now i want to convert that salary slip which is html page to PDF and push it to my server folder. i have done this with JQuery.
My question is:
1] can i push PDF created by JQuery on server?
2] Or any java library to convert that html to PDF?
Upvotes: 0
Views: 2911
Reputation: 211
You can use Java Library Flying Saucer for this. In your spring based project add the following dependencies in your pom.xml
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.13</version>
</dependency>
Upload the html file through POST and use this library's functions to convert in into pdf
You can read about Flying Saucer here
Upvotes: 1
Reputation: 369
JS:
var form_data = new FormData();
form_data.append('file', pdfFile);
$.ajax({
url: path/to/upload
data: form_data,
processData: false
})
Java:
public void uploadPdf(@RequestParam(name = "file") MultipartFile pdfFile)
Upvotes: 0