I'm wondering whether maybe the documents have differents settings of
the /NeedAppearances/ entry, and after merge it is set in a way that is
bad for you.
Does the rendering work properly if you change the entry manually?
doc.getDocumentCatalog().getAcroForm().setNeedAppearances()
Also, could it be you're rendering and THEN merging, i.e. from the same
PDDocument object?
Tilman
On 06.06.2023 13:47, sven.neufe...@ruv.de wrote:
Heys guys,
we're having an issue with some of our PDF documents that contains
interactive fields like Radio Buttons. In some cases we’ve to merge
PDF documents together (using the PDFMergerUtility) and when we try to
print that merged document these Button elements are not rendered
correctly, when using Apache PDFBox >= 2.0.22. Using the version
2.0.21 the buttons are rendered correctly.
I’m pretty new in the world of how PDF files work under the hood and
how the PDF structure and fields is defined in the standard. So I did
some research and could find out the reason for this misbehavior.
It looks like that issue had been introduced with this commit:
https://github.com/apache/pdfbox/commit/fe00cd3870f6d9ec27fcb55c89409b420ade0826
In the origin document (before entering the merge step) the
/NeedAppearances/ entry is set to true, but after the merge step the
entry’s changed to be false.
I could figure out that this line of code is the reason for that:
https://github.com/apache/pdfbox/blob/fe00cd3870f6d9ec27fcb55c89409b420ade0826/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java#L55
Is that an intended behaviour or is that an unintentionally sideeffect?
Kind regards
Sven Neufeind