Skip to content

Security

Why a PDF Signature Becomes Invalid After Editing

Why a digitally signed PDF shows an invalid signature after editing, merging or compressing, which changes are permitted after signing, and how to check.

Updated 9 min readSublimePDF Team

A signed PDF opened fine yesterday. Then someone merged it with a cover page, ran it through a compressor, or added a comment, and now the viewer says the signature is invalid, or that the document "has been altered or corrupted since it was signed". This article explains how PDF signatures detect changes, which edits are expected to break them and which are allowed, and how to fix the situation without guessing. It includes a local test with real signed files you can download and validate yourself.

This page is about cryptographic (certificate-based) signatures. A signature image drawn or typed onto a page is a different thing; see Electronic signatures: types, limits and PDF workflows for the distinction.

How a PDF signature detects changes

When a PDF is signed, the signing software:

  1. writes a signature dictionary into the file with an empty placeholder for the signature value;
  2. records a /ByteRange: two ranges of bytes that together cover the whole file except the placeholder;
  3. computes a digest (hash) of exactly those bytes, signs it with the signer's private key, and writes the result (a CMS/PKCS#7 object, RFC 5652) into the placeholder.

ISO 32000-1 (section 12.8) describes this: the digest is recomputed at validation and "differences in the digest values indicate that modifications have been made since the document was signed". The specification says the byte range should be the entire file at the moment of signing.

The consequence is strict. If even one of the signed bytes moves or changes, the digest no longer matches and the signature cannot be valid. There is no partial credit for "only the metadata changed".

Incremental updates: how changes can be added without breaking the bytes

PDF has a built-in way to change a file without touching existing bytes: the incremental update (ISO 32000-1, section 7.5.6). New or replaced objects plus a new cross-reference section are appended to the end of the file. The original bytes stay exactly where they were.

This is how a second person can sign the same PDF, and how a form can be filled after signing. The first signature's byte range still covers the first revision, and its digest still matches. A validator then has two questions to answer:

  • Is the signed revision intact? Recompute the digest over the byte range.
  • Are the later changes acceptable? Compare the later revisions with the signed one and decide whether they are allowed.

The second question is the hard one. The specification lists categories of permitted change, but as the pyHanko documentation notes, exactly how a validator should vet incremental updates is not specified precisely, and an appended revision can in principle change the document arbitrarily. Validators therefore apply their own rules, which is why two validators can disagree about the same file.

Which changes are permitted: approval and certification signatures

The signer can say in advance what may change. A certification signature (the first signature in the document, with a DocMDP transform) sets a permission level P (ISO 32000-1, section 12.8.2.2, Table 254):

PPermitted after certification
1No changes; any change invalidates the signature
2Filling in forms, instantiating page templates and signing
3As 2, plus creating, deleting and modifying annotations (comments)

An ordinary approval signature does not set DocMDP permissions itself. Validators still examine what was appended after it and flag changes that go beyond signing and form filling.

What actually breaks a signature: a local test

We built a fictional one-page agreement with one form field, signed it with a throwaway test certificate using pyHanko 0.32.0, applied typical edits, and validated every result with pyHanko. The scripts and every output file are kept in the site repository under scripts/research/signature/, and the PDFs are downloadable from /samples/fixtures/signature/.

Edit after signingHow it was savedpyHanko result
None (file)OriginalIntact, covers entire file
Fill the form field (file)Incremental updateIntact; changes classified as form filling; accepted
Add a comment (file)Incremental updateIntact, but change classified as "other"; rejected
Add visible text to the page (file)Incremental updateIntact, but change classified as "other"; rejected
Open and save with qpdf (file)Full rewriteDigest mismatch: "cryptographically unsound"
Open and save with pdf-lib (file)Full rewriteDigest mismatch: "cryptographically unsound"
Copy pages into a new PDF, as a merge does (file)New documentNo signature left at all
Fill the form field on a P=1 certified file (file)Incremental updateIntact, but violates the no-changes policy; rejected
Fill the form field on a P=2 certified fileIncremental updateIntact; permitted by the policy; accepted

Three patterns are worth remembering:

  1. Re-saving destroys the signature even if nothing visible changed. qpdf and pdf-lib both write a complete new file, so the signed bytes end up at different positions or in a different form. Many merge, compress, optimise, rotate and "edit" tools work this way, including SublimePDF's own browser tools, which save a new file with pdf-lib. Run a signed PDF through any of them and the signature will be invalid or gone.
  2. Merging usually removes the signature rather than breaking it. Copying pages into a new document carries the page content but not the signature field, so the result looks signed (the stamp is still drawn on the page) but contains no signature to validate.
  3. Incremental changes are judged by policy. Form filling passed where the policy allowed it and failed under P=1. Our comment was rejected by pyHanko, which vets changes on a reject-by-default basis; the specification permits comments under P=3, and other validators may classify the same comment differently. We did not test Adobe Acrobat or Reader.

To check one of the files yourself with the pyHanko command-line tool:

python3 -m venv /tmp/pyhanko && /tmp/pyhanko/bin/pip install pyhanko-cli
curl -O https://sublimepdf.com/samples/fixtures/signature/approval-incremental-fill-form.pdf
curl -O https://sublimepdf.com/samples/fixtures/signature/test-root-ca.pem
/tmp/pyhanko/bin/pyhanko sign validate --pretty-print \
  --trust test-root-ca.pem approval-incremental-fill-form.pdf

The test root certificate is published only so the demonstration can be reproduced. It is not trusted by any viewer and must never be added to a real trust store.

"Invalid" is not always about editing: integrity versus trust

Validators report several separate things, and an alarming summary can come from any of them:

  • Integrity. Does the digest of the byte range match? This is what editing breaks.
  • Modification policy. Are later incremental changes permitted?
  • Trust. Does the signer's certificate chain lead to a root the validator trusts? In our test, the untouched signed file was judged INVALID by pyHanko when no trust root was supplied ("No path to trust anchor found"), and VALID when the test root was supplied. Nothing about the file changed between those two runs.
  • Revocation and time. Was the certificate valid and unrevoked when the document was signed? Answering that years later needs a trusted timestamp and revocation data (OCSP responses or CRLs) embedded in the file, which is what long-term validation (LTV) profiles such as PAdES B-LT and B-LTA in ETSI EN 319 142-1 provide. Without them, a signature that validated on the day it was made may later show as "unknown" once the certificate expires.

Before concluding that someone tampered with a document, read the validator's detail panel and identify which of these four checks failed. A trust or revocation failure is a configuration or evidence problem, not an edit.

How to fix a broken signature

You cannot repair a signature by editing the file again. The digest was computed by the signer's key, and only the signer can produce a new one. What you can do:

  • Go back to the signed original. Keep it unchanged and archive it as received. If the copy you hold is the broken one, ask the sender for the original file.
  • Make changes before signing. Merge cover pages, compress images, fix typos and flatten forms first. Signing should be the last step that writes the file. If the document is generated by your own system, for example from HTML or a saved template with the HTML to PDF API, correct the source data and generate a new PDF for signing instead of editing the signed one.
  • Ask for re-signing if the content genuinely has to change after signing. A new revision with a new signature makes it clear what was approved when.
  • Package rather than merge. If you need to send a signed contract together with other documents, send them as separate files or in an archive (zip). Merging them into one PDF removes the signature as shown above.
  • Fill forms with software that saves incrementally. If a certified form must be filled after certification, the certifier should choose P=2 or P=3, and the filler should use software that appends rather than rewrites.
  • Validate with a tool you control and keep its report with the document, especially in audits. For a quick check without extra software, Microsoft's documentation says the PDF reader in Microsoft Edge can view and validate certificate-based digital signatures; we did not test Edge against the fixtures above.

What visual signature images do and do not do

Many signing workflows, including SublimePDF's Sign PDF tool, place a drawn or typed signature image on the page. That image is content like any other: it has no certificate, no digest and no byte range. A file that contains only a signature image cannot show "signature invalid" after editing, but for the same reason it gives no technical evidence that the document was unchanged after the image was placed. If you need tamper evidence, you need a certificate-based signature, and the edits described above will matter.

Terminology across standards and law

PDF tools say "digital signature" for the certificate-based mechanism described here. EU law uses different, legal terms: Regulation (EU) No 910/2014 (eIDAS) defines an "electronic signature" broadly, and sets out requirements for an "advanced electronic signature" in Article 26, including that it is linked to the signed data so that any subsequent change in the data is detectable. A PDF signature can be one technical way to meet that requirement, but whether a particular signature meets a legal standard depends on the certificate, the signing process and the jurisdiction. This article is not legal advice.

Summary

A PDF signature is a hash of exact bytes. Anything that rewrites the file (merging, compressing, optimising, most "save as" operations) breaks or removes it. Changes appended as incremental updates leave the signed bytes intact, and validators then judge them against the signer's permissions and their own policy. When a validator says "invalid", find out whether integrity, policy, trust or revocation failed, then go back to the signed original rather than trying to patch the edited copy.

Sources

  1. ISO 32000-1:2008 (Adobe public copy), 7.5.6 Incremental Updates; 12.8 Digital Signatures; 12.8.2.2 DocMDP, Table 254 · accessed 22 November 2026
  2. ISO 32000-2:2020 Document management - Portable document format - Part 2: PDF 2.0 (catalogue page) · accessed 22 November 2026
  3. ETSI EN 319 142-1 V1.1.1 PAdES digital signatures - Part 1: Building blocks and PAdES baseline signatures · accessed 22 November 2026
  4. RFC 5652 Cryptographic Message Syntax (CMS) · accessed 22 November 2026
  5. pyHanko documentation: validating signatures (CLI guide), incremental updates and difference analysis · accessed 22 November 2026
  6. Regulation (EU) No 910/2014 (eIDAS), Articles 3 and 26 (terminology) · accessed 23 November 2026
  7. Microsoft Learn: PDF reader in Microsoft Edge (view and validate certificate-based digital signatures) · accessed 23 November 2026