Search code examples
javapdfitextdigital-signature

how to add blank page in digitally signed pdf using java?


I want to insert blank page at end of the digitally PDF using itext library.and my confusion is adding pages will invalidate the existing signatures? Thank you.


Solution

  • To put Joeri's answer into context, have a look at the Adobe technical white paper Adobe Acrobat 9 Digital Signatures, Changes and Improvements, especially its section "Allowed and disallowed changes." Here Adobe clarifies the allowed changes (as seen by Acrobat 9 and up) that can be made to a certified or signed document without invalidating the signatures applied to the document.

    Allowed actions for certified documents

    Certified with no changes allowed

    Allowed

    • No changes allowed

    Disallowed

    • Digitally signing
    • Supplying form field values
    • Adding or editing annotations
    • Adding form fields
    • Changing page content

    Certified with form fill-in and digital signatures allowed

    Allowed

    • Supplying form field values
    • Digitally signing

    Disallowed

    • Adding or editing annotations
    • Adding form fields
    • Changing page content

    Certified with annotations, form fill-in, and digital signatures, allowed

    Allowed

    • Adding or editing annotations
    • Supplying form field values
    • Digitally signing

    Disallowed

    • Adding form fields
    • Changing page content

    Allowed actions for signed but uncertified documents

    Allowed

    • Adding signature fields (see Limitations on adding signature fields to signed but uncertified documents)
    • Adding or editing annotations
    • Supplying form field values
    • Digitally signing

    Disallowed

    • Adding form fields other than signature fields
    • Changing page content

    As you see "Changing page content" always is in the "Disallowed" category. As adding a page changes page content — afterwards there is at least a white page where there used to be nothing —, this is not allowed.

    (Even though not explicitly mentioned here, instantiating page templates most likely also is allowed whenever form fill-ins are allowed as that would conform to the PDF standard, cf. ISO 32000-1 section 12.8.2.2.2. But making use of such page templates would at least require the document to be specially prepared before signing, and your question sounds like the documents are already signed without any such preparation...)

    PS: Obviously even these allowed changes need to be added in append mode aka incremental updates. Anything else will break the signature for good. For some backgrounds see this answer.