Repository navigation
Closed
Labels
area/conformancePDF/A, PDF/UA, preflight, veraPDF gatesenhancementNew feature or requesttype/choremaintenance / infra
Description
Problem
PdfDocument builds the catalog in two places. (origin/main 1c61fa6,
src/VellumPdf.Kernel/Document/PdfDocument.cs.)
| Entry | Save path |
Signing path (WriteWithSignaturePlaceholders, :989) |
|---|---|---|
| Type, Pages, Metadata | :835-838 |
:1277-1280 |
| AcroForm | only if non-null (:859-860) |
always, built just above (:1272-1281) |
| Outlines, PageMode | :840-845 |
:1283-1288 |
| MarkInfo | :847-854 |
:1290-1296 |
| StructTreeRoot | :856-857 |
:1298-1299 |
| OutputIntents | from outputIntentsRef built earlier (:807-809, :862-863) |
built inline when Conformance != None (:1301-1304) |
| Lang | ApplyLanguage (:865) |
ApplyLanguage (:1306) |
| DisplayDocTitle | :867-872 |
:1308-1313 |
SaveAsync does not add a third copy: it runs Save on a buffer (:945-952). ApplyLanguage already exists as a
shared helper, and its comment says why: "Called from both the regular Save path and the signing placeholder path
so neither drifts out of sync" (:1758-1761).
Why it matters
Every new catalog entry in v2.4 has to go into both: /Names and /Dests (#241, #262), /PageLabels, the dual
pdfaid and pdfuaid XMP packet (#581), and ViewerPreferences. A missed copy is a signed document that
silently lacks an entry the unsigned one has.
Scope
- Extract one private catalog builder that both paths call. Inputs the paths differ in (AcroForm, output intent
reference) are parameters, not branches on which path called. - Pure refactor: the output of both paths stays byte-identical.
- Document, in the builder's comment, which entries are conditional and why.
Acceptance
- A golden test of the
Saveoutput and of thePrepareForSigningoutput for: a plain document, a tagged
document, PDF/UA-1, PDF/A-2u, a document with bookmarks, and a document with a form field, withTimestamppinned (PrepareForSigningreads
Timestamp ?? DateTimeOffset.UtcNowtoo,PdfDocument.cs:1186, so an unpinned golden would not be stable). The bytes equal
those of origin/main 1c61fa6 (hashes recorded before the refactor). - A test that adds a catalog entry through the builder and finds it in both outputs.
- Reproducible output: two
PdfDocumentinstances built identically withTimestamppinned give equal sha256 for
Saveand forPrepareForSigning. - No public API change (
PublicAPI.*.txtuntouched). - Mutation: dropping
DisplayDocTitlefrom the builder fails the PDF/UA-1 test in both paths.
Relates to
- Kernel: claim PDF/A-2a and PDF/UA-1 in one file #581 (dual claim), Kernel: a structure element cannot hold mixed kids (MCID, MCR, OBJR, element) or content on several pages #604, Kernel: write a /Names name tree and the catalog /Names entry #241 (name tree), Kernel: page labels and named destinations #262 (named destinations and page labels).
Metadata
Metadata
Assignees
Labels
area/conformancePDF/A, PDF/UA, preflight, veraPDF gatesenhancementNew feature or requesttype/choremaintenance / infra
Activity
feat(kernel): internal name-tree and number-tree writers (#622)
test(kernel): pin the catalog bytes of Save and the signing path (#626)