[PR #2473] [MERGED] fix: match cert and audit log page dimensions to source document #2328

Closed
opened 2026-02-26 20:33:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/2473
Author: @ephraimduncan
Created: 2/11/2026
Status: Merged
Merged: 2/12/2026
Merged by: @Mythie

Base: mainHead: fix/cert-page-width-mismatch


📝 Commits (9)

  • eaa7bdd fix: match cert and audit log page dimensions to source document
  • f2b9f3b chore: add cert page width mismatch plan
  • 0eaf43f refactor: remove unnecessary fallback and unused import in seal handler
  • 05e6ba6 refactor: simplify cert page dimension code
  • faedcbd fix: tidy logic
  • 21674e6 fix: update visual regression images and cert dimension tests for certificate autosizing
  • bc82e4e Merge remote-tracking branch 'origin/main' into fix/cert-page-width-mismatch
  • 1042d71 fix: add missing additionalAuditLogs and finalEnvelopeStatus to certificate payload
  • 3c3a033 fix: update regeneration test to distribute for prefill values

📊 Changes

21 files changed (+508 additions, -68 deletions)

View changed files

.agents/plans/fresh-gold-rock-cert-page-width-mismatch.md (+168 -0)
assets/a4-size.pdf (+0 -0)
assets/letter-size.pdf (+0 -0)
assets/tabloid-landscape.pdf (+0 -0)
packages/app-tests/e2e/envelopes/cert-page-dimensions.spec.ts (+218 -0)
📝 packages/app-tests/e2e/envelopes/envelope-alignment.spec.ts (+18 -2)
📝 packages/app-tests/visual-regression/alignment-pdf-0.png (+0 -0)
📝 packages/app-tests/visual-regression/alignment-pdf-1.png (+0 -0)
📝 packages/app-tests/visual-regression/alignment-pdf-2.png (+0 -0)
📝 packages/app-tests/visual-regression/alignment-pdf-3.png (+0 -0)
📝 packages/app-tests/visual-regression/blank-certificate.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-0.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-1.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-2.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-3.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-4.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-5.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-6.png (+0 -0)
📝 packages/app-tests/visual-regression/field-meta-pdf-7.png (+0 -0)
📝 packages/lib/jobs/definitions/internal/seal-document.handler.ts (+81 -66)

...and 1 more files

📄 Description

Demo - Sample Documents of different sizes.

a4-size_signed.pdf
letter-size_signed.pdf
tabloid-landscape_signed.pdf

Description

Certificate and audit log pages were generated with hardcoded A4 dimensions (595×842) regardless of the actual document page sizes. When the source document uses a different page size (e.g., Letter, Legal, or custom dimensions), the certificate/audit log pages ended up with a different width than the document pages, causing problems with courts and printers that expect uniform page dimensions throughout a PDF.

This fix reads the last page dimensions from each envelope item's PDF and generates size-matched certificate and audit log pages.

Changes Made

  • Added getLastPageDimensions utility to get-page-size.ts using @libpdf/core, with Math.round() and minimum dimension enforcement (falls back to A4 below 300pt)
  • Updated seal-document.handler.ts to read last-page dimensions per envelope item, deduplicate by size key, and generate cert/audit PDFs per unique page size
  • Updated download-document-certificate.ts to read page dimensions from the document's PDF instead of hardcoding A4
  • Updated download-document-audit-logs.ts to read page dimensions from the document's PDF instead of hardcoding A4
  • Added E2E test (cert-page-dimensions.spec.ts) that seals a Letter-size PDF and asserts all pages in the output have matching dimensions
  • Added PDF test fixtures: letter-size.pdf (612×792), a4-size.pdf (595×842), tabloid-landscape.pdf (1224×792)

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

  • The deprecated Playwright PDF path (NEXT_PRIVATE_USE_PLAYWRIGHT_PDF) remains A4-only as it is behind a feature flag and will be removed. No changes made to that path.
  • For single-document envelopes (most common case), this produces identical performance — one cert/audit generation, same as before.
  • Multi-document envelopes with the same page sizes also produce one generation due to deduplication by size key.

🔄 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/2473 **Author:** [@ephraimduncan](https://github.com/ephraimduncan) **Created:** 2/11/2026 **Status:** ✅ Merged **Merged:** 2/12/2026 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/cert-page-width-mismatch` --- ### 📝 Commits (9) - [`eaa7bdd`](https://github.com/documenso/documenso/commit/eaa7bdd313b96eda6e1cc1519151ce1e8e9b369c) fix: match cert and audit log page dimensions to source document - [`f2b9f3b`](https://github.com/documenso/documenso/commit/f2b9f3ba366424d37420c70e7ee7965f54f7ffde) chore: add cert page width mismatch plan - [`0eaf43f`](https://github.com/documenso/documenso/commit/0eaf43f6891594d3a2fcaa7403184121f681a4fe) refactor: remove unnecessary fallback and unused import in seal handler - [`05e6ba6`](https://github.com/documenso/documenso/commit/05e6ba6af1cf240c756a4140ba87a37da7c3dd4a) refactor: simplify cert page dimension code - [`faedcbd`](https://github.com/documenso/documenso/commit/faedcbd787104062827ff66d025d70b3506240ac) fix: tidy logic - [`21674e6`](https://github.com/documenso/documenso/commit/21674e6d6a5e03066dacd51c4f01f2146489e402) fix: update visual regression images and cert dimension tests for certificate autosizing - [`bc82e4e`](https://github.com/documenso/documenso/commit/bc82e4edba82e09180b88208c30a74acbde7fd6d) Merge remote-tracking branch 'origin/main' into fix/cert-page-width-mismatch - [`1042d71`](https://github.com/documenso/documenso/commit/1042d71ff245a80b4fcb25b193fe0a3d291e96be) fix: add missing additionalAuditLogs and finalEnvelopeStatus to certificate payload - [`3c3a033`](https://github.com/documenso/documenso/commit/3c3a0335b8a279791b3689fa9cc9fb848c7788a8) fix: update regeneration test to distribute for prefill values ### 📊 Changes **21 files changed** (+508 additions, -68 deletions) <details> <summary>View changed files</summary> ➕ `.agents/plans/fresh-gold-rock-cert-page-width-mismatch.md` (+168 -0) ➕ `assets/a4-size.pdf` (+0 -0) ➕ `assets/letter-size.pdf` (+0 -0) ➕ `assets/tabloid-landscape.pdf` (+0 -0) ➕ `packages/app-tests/e2e/envelopes/cert-page-dimensions.spec.ts` (+218 -0) 📝 `packages/app-tests/e2e/envelopes/envelope-alignment.spec.ts` (+18 -2) 📝 `packages/app-tests/visual-regression/alignment-pdf-0.png` (+0 -0) 📝 `packages/app-tests/visual-regression/alignment-pdf-1.png` (+0 -0) 📝 `packages/app-tests/visual-regression/alignment-pdf-2.png` (+0 -0) 📝 `packages/app-tests/visual-regression/alignment-pdf-3.png` (+0 -0) 📝 `packages/app-tests/visual-regression/blank-certificate.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-0.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-1.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-2.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-3.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-4.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-5.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-6.png` (+0 -0) 📝 `packages/app-tests/visual-regression/field-meta-pdf-7.png` (+0 -0) 📝 `packages/lib/jobs/definitions/internal/seal-document.handler.ts` (+81 -66) _...and 1 more files_ </details> ### 📄 Description ## Demo - Sample Documents of different sizes. [a4-size_signed.pdf](https://github.com/user-attachments/files/25229421/a4-size_signed.pdf) [letter-size_signed.pdf](https://github.com/user-attachments/files/25229423/letter-size_signed.pdf) [tabloid-landscape_signed.pdf](https://github.com/user-attachments/files/25229424/tabloid-landscape_signed.pdf) ## Description Certificate and audit log pages were generated with hardcoded A4 dimensions (595×842) regardless of the actual document page sizes. When the source document uses a different page size (e.g., Letter, Legal, or custom dimensions), the certificate/audit log pages ended up with a different width than the document pages, causing problems with courts and printers that expect uniform page dimensions throughout a PDF. This fix reads the last page dimensions from each envelope item's PDF and generates size-matched certificate and audit log pages. ## Changes Made - Added `getLastPageDimensions` utility to `get-page-size.ts` using `@libpdf/core`, with `Math.round()` and minimum dimension enforcement (falls back to A4 below 300pt) - Updated `seal-document.handler.ts` to read last-page dimensions per envelope item, deduplicate by size key, and generate cert/audit PDFs per unique page size - Updated `download-document-certificate.ts` to read page dimensions from the document's PDF instead of hardcoding A4 - Updated `download-document-audit-logs.ts` to read page dimensions from the document's PDF instead of hardcoding A4 - Added E2E test (`cert-page-dimensions.spec.ts`) that seals a Letter-size PDF and asserts all pages in the output have matching dimensions - Added PDF test fixtures: `letter-size.pdf` (612×792), `a4-size.pdf` (595×842), `tabloid-landscape.pdf` (1224×792) ## Checklist - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [ ] I have updated the documentation to reflect these changes, if applicable. - [x] I have followed the project's coding style guidelines. - [ ] I have addressed the code review feedback from the previous submission, if applicable. ## Additional Notes - The deprecated Playwright PDF path (`NEXT_PRIVATE_USE_PLAYWRIGHT_PDF`) remains A4-only as it is behind a feature flag and will be removed. No changes made to that path. - For single-document envelopes (most common case), this produces identical performance — one cert/audit generation, same as before. - Multi-document envelopes with the same page sizes also produce one generation due to deduplication by size key. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 20:33:24 +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#2328
No description provided.