Skip to Content

Merging Digitally Signed Documents & Flattening Digital Signatures to Page Content

Estimated Reading Time: 3 Minutes

The Details

When a PDF that contains a digital signature is merged with other PDF files, the resulting document's digital signature is invalidated, and Acrobat (or other viewers) may display a warning about this. If the goal is to maintain the visual appearance of a signature while merging, but not necessarily keep the secure aspect of it, then we must convert the visible signature appearance into static page content (flatten). The issue is, a simple flatten operation alone may not achieve this effect.

Why this happens: A PDF digital signature is typically represented on a page by a Widget annotation associated with a form field which contains the signature data. Merely flattening the Widget annotation's normal appearance into the page's content will not remove the form field with the signature data. PDF viewers examine those structures and will still treat the document as containing a signature—even if its visual appearance has been rasterized or merged into the page content. As a result, merging or combining files triggers signature validation checks and warnings.

To summarize the key technical points behind this problem:

  • Visible signature appearance typically comes from an Annotation's appearance stream associated with a signature form field.
  • Signature objects and form field dictionaries (AcroForm) can remain in the document when the Annotation's appearance is flattened into the page content.
  • Viewers like Acrobat use the presence of signature-related dictionaries to show signature panels and warnings; therefore, to stop that behavior you must both render the visual appearance into page content and remove the form/signature metadata.

Resolution Summary

Two essential changes required to resolve the issue:

  1. Flatten all signature-related annotations on every page: iterate over every page in the document and flatten each Annotation’s appearance stream into the page content. The default FlattenAnnotations sample located on GitHub will flatten annotations on a single page by default; a modification must be made to loop over the full page range.
  2. Remove the AcroForm dictionary from the document Root Catalog after all annotations have been flattened. This prevents PDF viewers from recognizing residual form or signature data and displaying signature warnings. In the CPlusPlus interface, this can be done using a call like this one: CosDictRemove(cosDocGetRoot(cosDoc), ASAtomFromString("AcroForm"));

Notes, limitations, and best practices

  • Loss of cryptographic validity: Flattening signatures to static objects or merging signed documents with other documents destroys the cryptographic signature. This action is irreversible for that file. Only proceed when signature validity is not required.
  • Always operate on a copy of the original signed PDF to preserve the original signed file.
  • For bulk processing, ensure you handle all annotation types and pages; omissions will leave residual form structures and trigger viewer warnings.

How to get additional help if needed

If you need further assistance implementing a multi-page annotation flattening workflow or updating sample code to remove the AcroForm dictionary, contact support at: tech_support@datalogics.com

When contacting support, include:

  • A brief description of the desired outcome (for example: "Preserve visual appearance of digital signatures while removing signature fields and AcroForm so merging does not trigger warnings").
  • Sample PDF (if possible) or a description of how signatures are embedded (single page vs multiple pages, presence of AcroForm, any custom appearance streams).
  • The version of the PDF library or tools being used (for example, APDFL version), and a brief description of which sample utilities you attempted and their behavior.

This article describes how to render digital signature appearances into static page content and remove form-level metadata so viewers do not treat a PDF as signed. For implementation help, contact support using the details above.

Merging Digitally Signed Documents & Flattening Digital Signatures to Page Content
  • COMMENT