[PR #1062] [MERGED] fix: normalize and flatten annotations #1352

Closed
opened 2026-02-26 19:32:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/1062
Author: @Mythie
Created: 3/27/2024
Status: Merged
Merged: 3/27/2024
Merged by: @Mythie

Base: mainHead: fix/flatten-annotations


📝 Commits (1)

  • b491bd4 fix: normalize and flatten annotations

📊 Changes

4 files changed (+149 additions, -71 deletions)

View changed files

📝 packages/lib/server-only/document/seal-document.ts (+7 -26)
packages/lib/server-only/pdf/flatten-annotations.ts (+63 -0)
packages/lib/server-only/pdf/normalize-signature-appearances.ts (+26 -0)
📝 packages/signing/helpers/add-signing-placeholder.ts (+53 -45)

📄 Description

This change flattens and normalizes annotation and widget layers within the PDF document removing items that can be accidentally modified after signing which would void the signature attached to the document.

Initially this change was just to assign to an ArcoForm object in the document catalog if it existed but quickly turned into the above.

When annotations aren't flattened Adobe PDF will say that the signature needs to be validated and upon doing so will become invalid due to the annotation layers being touched.

To resolve this I set out to flatten and remove the annotations by pulling out their normal appearances if they are present, converting them into xobjects and then drawing those using the drawObject operator.

This resolves a critical issue the users experienced during the signing flow when they had marked up a document using annotations in pdf editors.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/1062 **Author:** [@Mythie](https://github.com/Mythie) **Created:** 3/27/2024 **Status:** ✅ Merged **Merged:** 3/27/2024 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/flatten-annotations` --- ### 📝 Commits (1) - [`b491bd4`](https://github.com/documenso/documenso/commit/b491bd4db9aeca01820ae6a5df413b4f938999b6) fix: normalize and flatten annotations ### 📊 Changes **4 files changed** (+149 additions, -71 deletions) <details> <summary>View changed files</summary> 📝 `packages/lib/server-only/document/seal-document.ts` (+7 -26) ➕ `packages/lib/server-only/pdf/flatten-annotations.ts` (+63 -0) ➕ `packages/lib/server-only/pdf/normalize-signature-appearances.ts` (+26 -0) 📝 `packages/signing/helpers/add-signing-placeholder.ts` (+53 -45) </details> ### 📄 Description This change flattens and normalizes annotation and widget layers within the PDF document removing items that can be accidentally modified after signing which would void the signature attached to the document. Initially this change was just to assign to an ArcoForm object in the document catalog if it existed but quickly turned into the above. When annotations aren't flattened Adobe PDF will say that the signature needs to be validated and upon doing so will become invalid due to the annotation layers being touched. To resolve this I set out to flatten and remove the annotations by pulling out their normal appearances if they are present, converting them into xobjects and then drawing those using the drawObject operator. This resolves a critical issue the users experienced during the signing flow when they had marked up a document using annotations in pdf editors. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:32:53 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1352
No description provided.