Remove PDF/A annotatio from PDDocument after merge

I use pdfbox and I want to merge PDF documents. This is not a problem. However, the second file uses the PDF/A annotation. After merging, this annotation is still part of the PDF file.

But I need to sign the document using AcroField, but with the annotation this is not possible.

How can I solve this? Thanks.


Annotations and PDF/A are two different things. The PDF/A property is in the XMP metadata, however it is likely that it is no longer a valid PDF/A file after merge anyway.

The easiest way to remove the XMP metadata (if you don’t need it) is to call doc.getDocumentCatalog().setMetadata(null).

If a more fine-tuned approach is needed, one can combine the example (gets the xmp metadata) with the example (saves the metadata) and try to call xmp.removeSchema(xmp.getPDFExtensionSchema()).