Thank you! I've added a source code comment and also improved the example.

Have a great weekend!

Tilman

Am 19.02.2021 um 16:36 schrieb Waldemar Dick:
Thanks for all the help!

The actual problem was quite trivial: the widget annotation of the signature field was missing the “print” annotation flag. There was no flag set at all. During signing PDFBox will set this flag and this caused the unexpected amount of updated objects in the incremental save.

What PDFBox does is totally correct.

If I set the flag on all widgets before signing, everything is fine.


Regards,
Waldemar


On 18. 02 2021, at 17:48, Tilman Hausherr <[email protected] <mailto:[email protected]>> wrote:

What you could do if is to add this in COSWriter.prepareIncrement():

        PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm(null);
        if (acroForm != null && !acroForm.getCOSObject().isNeedToBeUpdated())
        {
            // find fields that need to be updated, these may be missed if there is no "path" to them
            for (PDField field : acroForm.getFieldTree())
            {
                if (field.getCOSObject().isNeedToBeUpdated() && !objectsToWrite.contains(field.getCOSObject()))
                {
objectsToWrite.add(field.getCOSObject());
                }
            }
        }

In PDDocument, find the line

page.getCOSObject().setNeedToBeUpdated(true);

and move this line below the line

annotations.add(widget);


Also make sure that the first signing doesn't create a "certified" PDF. That is what you get when calling SigUtils.setMDPPermission().

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] <mailto:[email protected]> For additional commands, e-mail: [email protected] <mailto:[email protected]>




Reply via email to