Pass HTML data to PDF file

Asked

Viewed 234 times

0

Talk guys, I have a big problem here for you to help me.

I have a PDF (with fields I can fill in) and I also have an HTML form. What I need to do is take the input values and send them to this PDF template by filling in the appropriate fields.

The problem is I have no idea how to do that. I’ve searched the internet and nothing.

  • Take a look at XML, maybe this can help you turn this data into an organized form

1 answer

1


This is Sallazar, all right?!

I’ve used two ways to edit PDF’s.

One of them is editing on the front end itself using the libraries jsPDF and/or html2canvas, both are javascript.

The html2canvas is used to convert all HTML content - which may be stylized - into an image. The jsPDF is responsible for generating the PDF.

I used both libraries because I had a PNG image resulting from a PDF -> PNG conversion; I defined this image as the background of my body and made all the necessary edits via HTML and CSS. After that, I converted all my HTML content stylized by CSS into an image via html2canvas and then manipulated the result with jsPDF to generate the PDF. Being a PDF generated from an image, the final file was very large (>=5Mb);

The other way is to use the Zendpdf to upload your PDF and make edits with PHP and the library. This way you can create and edit the PDF, keeping the text in text format and the file gains some Kbytes compared to the template.

There are plenty of tutorial on the internet for both ways. I recommend using Zendpdf.

  • Massa, I’ll take a look at this Zendpdf. Now, I’m using JSP in the project and not PHP, da para fazer?

  • With JSP you can use jsPDF but get into the case I mentioned above. You’ll need to convert your PDF into an image, set it to background-image of all the content you want to display in pdf and make the changes.

  • I researched creating PDF’s in java and found this solution: https://www.baeldung.com/java-pdf-creation

  • In case I have resolved your doubt and really helped you, vote as the best answer so that the question is closed xD Abraços Sallazar!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.