Search code examples
javapdfboxpdf-form

PDFBOX Flatten Acro-form causes displaced text from original location


I used PDFBOX to fill form and then flatten it using api. Resulting PDF is not correctly displayed

Link TO PDF

I used PDFBox 2.0.21

sample code to flatten form

    val sourceDocument = getTemplate(templatePath)
    val form = sourceDocument.documentCatalog.acroForm
    fillHeader(form, headerParam, currentPage, totalPages, it)
    fillData(form, it, currentPage)
    form.flatten(form.fieldTree.toList(),false)

full code is posted at Full code

I am not sure if this problem is PDFBox or Adobe

Need help


Solution

  • Updating to version 2.0.22 fixes this problem with flattening, which was described here. Version 2.0.22 was released at the end of 2020.

    Always use the latest version, use the maven versions plugin to detect the existence of new versions.