Add Text in Existing PDF File

0
Hi Guys, I have to Add text(user name which is login) in Existing PDF in Mendix( 8.18.0).I am trying to implement By Java Actions But I Didn’t get Proper Solution For that.If Anyone have idea about it please Share in comments.   Thanks and Regards Disha sharma
asked
1 answers
2

HI Disha, You can do it by two ways. 

Method 1 : Using overlay

- Overlay is nothing but a Mendix document Template with the actual text formatted the way you need

- In a Microflow, you can retrieve your existing document and generate a new document from overlay

- Pass these two documents to a Java action

- Apache PDFBox the default PDF framework for Mendix has Overlay class, you can use it to merge your documents

- Refer sample programs here : https://www.programcreek.com/java-api-examples/?api=org.apache.pdfbox.multipdf.Overlay

UPDATE: 

- Use OverlayPdfDocument from community commons

Thank you @Ronald. Completely forgot about those classes

Method 2 : Directly write the Text in position within the document

- In the microflow, retrieve the document

- Pass the document to java action along with the text to be written on it

- Use PDPageContentStream to write text in the PDF

- Refer : https://www.tutorialspoint.com/pdfbox/pdfbox_adding_text.htm

I have used both method in different contexts and both works just fine. 

 

answered