Let’s say I have a general template template.pdf
file. I can use use PDFBox and AcroForm
to change field values.
Now, I want to add another template (line_template.pdf
) to the same document and repeat it a few times.
Conceptually this should work like like this:
When I load the documents and use PDFMergerUtility
– documents are added as new pages. However, I’d like to combine them into single page (overlay it as shown on the picture).
Is it possible with PDF Box to overlay documents (or forms to be precise) on each other like in the picture?
val document = PDDocument()
val template = PDDocument.load(File("template.pdf"))
// Update template fields
val line = PDDocument.load(File("line_template.pdf"))
// Update line fields
val merger = PDFMergerUtility()
merger.appendDocument(document, template)
merger.appendDocument(document, line)
document.save("invoice.pdf")
document.close();
1