[
https://issues.apache.org/jira/browse/PDFBOX-3891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16120699#comment-16120699
]
Haiko Strotbek commented on PDFBOX-3891:
----------------------------------------
Sorry for not being specific enough.
Renaming the fields sounds like an acceptable workaround to me. (I really need
a solution for this)
I read some code from PDFMergerUtility and as far as I understood this code
snippet should do the trick:
final PDDocument pdf = PDDocument.load(inStream);
final PDDocumentCatalog catalog = pdf.getDocumentCatalog();
final PDAcroForm acroForm = catalog.getAcroForm();
if (null != acroForm && !acroForm.xfaIsDynamic()) {
// is it enough to rename the root names?
for (final PDField field : acroForm.getFields()) {
field.setPartialName("doc" + index + field.getPartialName());
}
}
Unfortunately, it doesn't work for the attached document: acroForm.getFields()
returns an empty list.
But the code does work for other documents I have.
This may be the cause why PDFMergeUtility.mergeAcroForm(...) is not able to
merge the forms correctly; there is already a similar logic in place.
> Missing data if document is merged with itself
> ----------------------------------------------
>
> Key: PDFBOX-3891
> URL: https://issues.apache.org/jira/browse/PDFBOX-3891
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm, Utilities
> Affects Versions: 2.0.7
> Reporter: Haiko Strotbek
> Attachments: MergeTest.java, merge-test-merged.pdf, merge-test.pdf
>
>
> When using PDFMergerUtility to merge the attached PDF twice into one document
> there may be data missing.
> To be more specific: In this case the data on page 1 looks fine, but page 28
> is empty. My expectation is that page 28 is identical to page 1 (the document
> has 27 pages).
> Of course that's not a common use case. But I can reproduce this behaviour
> with other documents which are not identical, but similar.
> I think this might be related to PDFBOX-3111 and PDFBOX-3218.
> What is the trigger for this and is there a workaround?
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]