Repository navigation
Conversation
veraPDF and PdfPreflight pass tagged Layout output that is not accessible, so the fixes planned for it need a test that fails on today's defect and passes on the fix. This dumper prints the structure tree, the marked content each element claims, the parent tree and the annotations as text, and prints a problem line where they disagree. It walks /K and /ParentTree itself instead of reusing StructureTree, which collapses MCID, MCR and OBJR kids into a flag, de-duplicates by object number and truncates silently at its caps. Show operands are decoded through /ToUnicode, since the Reader's text extraction returns nothing for Type0 fonts and has no marked-content awareness. Unit tests build the PDFs by hand, because the writer cannot yet produce MCR or OBJR kids, attribute arrays, or a wrong parent tree.
Nine Layout documents (split paragraph, three-page table, nested list, header and footer bands, images, runs split inside a word, headings, empty cell, language overrides) are dumped with the structure dumper and pinned with Verify. Each golden's first line names the audit findings it still shows, so the change that fixes one updates the golden in the same diff instead of passing unnoticed. Each case is built twice and the two dumps compared, so a golden never rests on a nondeterministic run.
Review of the first dumper found inputs that crashed or silently skipped what a golden has to show. A destination dictionary whose /D points at itself overflowed the stack; named property lists printed as unresolved because the Reader exposes resources only around image callbacks; a form drawn inside a sequence printed as UNMARKED; unclosed sequences, a /P that is not the walking parent, an out-of-range MCID or key and an odd /Nums were not reported at all. The dumper now tracks resources itself, reports each of those as a marker line, counts every marker in the footer, expands a shared attribute object once, caps printed values with a per-dump budget, marks line breaks so a run boundary inside a word is visible, and checks an OBJR through its own target's /StructParent whatever the target is. ToUnicodeMap keys codes by byte length, searches ranges by binary search and cannot throw on wide ranges. A form that carries MCIDs and is drawn more than once is reported as MULTI-DO: ISO 32000-2 14.7.5.2 allows such a form into the structure only by the Do-inside-a-sequence method. Each behaviour has a test on a hand-built file.
The goldens now carry the text-line markers and per-page /Tabs the hardened dumper prints, and each header lists every defect the golden visibly shows (borders as bare artifacts, missing /BBox, split items). Case 6 uses a smaller font so every run of the findings' paragraph sits on one text line, which makes the extra space inside "astro logie" visible. Case 10 records a single list item split across a page break: the continuation becomes a second L whose LI has no Lbl. A table row taller than a page is refused by the layout engine with an InvalidOperationException instead of being split, so there is no table counterpart. Two builds in one process must give equal dumps; whether that holds across processes is what the Verify comparison and CI check.
Round-two review found that each round-one fix covered the sites it named and left their siblings: some output lines were uncharged, some document strings printed raw, problems were recognised by matching the printed text, and integer fields were read three different ways. Every line now goes through one Note or Problem call that charges a single 8,000,000 character budget and, for a problem, increments the counter the footer prints, so text that looks like a marker (a forged name, a /Contents string) is no longer counted and cannot add a line. Document text goes through one Safe (cut, then escape). Element paths are computed from the parent chain, capped to their tail, instead of stored. One ReadInt reports a real, negative or oversized integer as BAD-* wherever an integer is required. A named property list that does not resolve is a counted BAD-PROPERTIES. ToUnicodeMap flattens its ranges into disjoint segments at first use (first range in the file wins) and binary-searches them, and a CMap is parsed once per document. A form with MCIDs painted inside an MCID sequence is reported per ISO 32000-2 14.7.5.2. The goldens are unchanged: none of this changes what the writer's output prints.
The earlier complexity test put the wide range first, where first-wins leaves a single segment and a linear scan costs nothing, so it could not tell a scan from a binary search. With the wide range last there are about 100,000 segments, and a linear lookup fails the comparison bound.
The dumper is a test oracle that reads PDFs generated by this repository's tests and bytes they write by hand. Its guarantee is termination with a diagnosable result and bounded output, plus cheap guards; the cost of pathological input is documented as out of scope. Show text stops decoding once 200 characters are produced and reports the codes left, and a /ToUnicode destination over 512 bytes (ISO 32000-2 9.10.3) is unmapped, so a 1-byte code expanding to 256 characters no longer builds the whole string first. An element line prints at most 32 keys and no line passes 20,000 characters. Presence checks treat the null object and a reference to nothing as absent, and revision numbers in /A and /C are read as integers with BAD-REVISION on a bad one. Tests: the allocation of a 4,000-code show string, a line with 7,000 keys, check lines that alone exceed the output budget, null and dangling values, bad revision numbers. The goldens' first lines now list A11Y-04 and A11Y-17 (cases 4, 10), A11Y-09 (case 10) and A11Y-16 (cases 2, 8). Comments are corrected: the ISO 32000-2 14.7.5.2 rule for forms, the named-destination clause, and the resource fallback deviation.
An element line with 32 keys of 32 dictionaries of 32 arrays is about 80,000 characters before the 20,000 cap, and has no more than the 32 keys the key cap allows, so only the line cap shortens it.
The caps paragraph said a name was cut at 64 or 512 characters and that a capped value prints in at most 1,600; it now separates strings, keys and printed names (200) from the names that label something (64), and gives the real worst cases for a shown text and a path. The guarantee now says the dumper may also end with an exception from the Reader. Comments are corrected against ISO 32000-2: the form clause quotes the sentence it paraphrases, the named-destination comment describes the dictionary form of 12.3.2.4, the revision number comment gives the reason a negative one is reported (14.7.6.3, NOTE 4), and the resource fallback comment says when the page's and the invoker's resources differ. Tabs, Lang, MarkInfo, DisplayDocTitle and a GoTo action's /D now go through the same absent-if-null helper as the other presence checks.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1 of A11Y-12. Tests only: nothing under
src/changes, and no public API file changes.Summary
The 2026-11-16 handbook research measured veraPDF 1.30.2
ua1andPdfPreflightpassing taggedLayout output that is not accessible (A11Y-02, -04, -05, -06, -07, -09, -15 among others). The tagging PRs that follow need a test that fails on today's
defect and passes on the fix, and neither validator can be that test.
This PR adds the instrument and records today's output with it:
StructureDumperinVellumPdf.Conformance.Testsprints a PDF's structure tree, each page'smarked content and each page's annotations as text. It checks the parent tree against them and
prints a problem line where they disagree. It walks
/Kand/ParentTreeitself, becauseStructureTreecollapses MCID, MCR and OBJR kids into a flag, de-duplicates by object number andtruncates silently at its caps. Shown text is decoded through
/ToUnicode, because the Reader'stext extraction has no marked-content awareness. A
linemarker shows where a text line breaks, soa run boundary inside a word is visible.
findings it still shows, so the PR that fixes one finding changes that golden in the same diff.
The problem-line footer reports structural inconsistencies, not PDF/UA findings. A golden can show a
defect with
0 problem line(s).What the goldens show
All ten documents use
Conformance = PdfUA1, a title,Language = "nl-NL", an A4 page, the embeddedDejaVu Sans and an explicit style on every element. The "emphasis" runs in case 6 differ by colour,
because no bold face is embedded in the test project.
{page}and{pages}AltTextLinkUrirun mid-sentenceLanguageoverrides in an nl-NL documentA table row taller than a page is refused by the layout engine with an
InvalidOperationException("An element is too tall to fit on a single page") instead of being split. That was observed for one
input, a 60-sentence cell in a 300 pt column. There is therefore no table counterpart to case 10.
How the dumper is bounded
The dumper reads trusted test data: PDFs that this repository's tests generate and bytes they write
by hand. On any input it terminates with a dump, an
InvalidOperationExceptionnaming the cap it hit,or an exception from the Reader. Its output is bounded, and no single line or printed value is
unbounded. The cost of pathological input is not bounded beyond termination and is out of scope.
Three examples are named in the XML remarks: descending
/ToUnicoderanges that each cover what theones before them left open make flattening quadratic; a property list is sorted again for every
BDCthat names it; the CMap tokenizer holds every token of the stream at once.Caps that throw an
InvalidOperationExceptioninstead of truncating:marked-content depth 64 (counted across a page and the forms it draws);
A line longer than 20,000 characters is cut, not refused.
Caps on a single printed value, each saying so with
…(+N):/Sand its role-map target, an annotation's/Subtype, an action's/S, a destination's name or fit type, an OBJR target's type): 64;after 100 bytes;
prints in at most 203.
The cut is made on the source text, before escaping, and one UTF-16 unit escapes to at most eight
characters, so a string, key or name prints in at most 1,600 characters before its suffix and a shown
text in at most 3,640. A
/ToUnicodedestination over 512 bytes is unmapped (ISO 32000-2 9.10.3).Problems are counted when they are emitted. Nothing reads the printed text back to decide what was a
problem, so a name such as
/Span#0AORPHANstays on its line and is not counted. Everydocument-controlled string goes through one escape and cap. Integer fields the checks read (MCIDs,
parent-tree keys,
/StructParent(s),/ParentTreeNextKey, revision numbers) go through one readerthat reports a real, negative or oversized value as
BAD-*; the null object and a reference tonothing are absent.
Two reports follow ISO 32000-2 14.7.5.2. A form that carries MCIDs and is drawn more than once is
reported as
MULTI-DO, and a form with MCIDs painted inside an MCID-bearing sequence is reported asFORM-MCIDS-INSIDE-CONTENT-ITEM.Verified
Counts are from runs on the head
1acac44, without the external oracles.LayoutStructureGoldenTests10,StructureDumperTests22,StructureDumperHardeningTests26,StructureDumperClassTests25. Thatis 83 tests.
dotnet test --project tests/VellumPdf.Conformance.Tests -c Release: 1408 total, 1125 succeeded,283 skipped, 0 failed. The 283 skips are the oracle tests.
dotnet build VellumPdf.slnx -c Releasegives 0 warnings and 0 errors.dotnet format VellumPdf.slnx --verify-no-changesandeng/clean-room-check.ps1pass.Mutation proofs, each run in a detached worktree and reverted. The head each was measured on is
stated, because the dumper changed between rounds.
Writer and Kernel mutations, on
66b7e12(Debug):ListRenderer.cs:226"LI"to"Div"UNMARKED show "Kop 1"and the three other band linesPdfStructureTree.cs:214read shifted:refList.Add(indexed[(i + 1) % n] ?? PdfNull.Instance)PARENTTREE MISMATCHlines such asparent tree has Document/L[0]/LI[0]/LBody[1]/P[0], element holding it is Document/L[0]/LI[0]/Lbl[0]/P[0]. Cases 1 and 4 do not fail: each of their pages has a single MCID.An earlier form of the last mutation, writing
indexed[(elem.Mcid + 1) % n], throws atSavefrom theKernel's duplicate-MCID guard and never reaches a golden, so it is not used as the proof.
Dumper mutations, each failing the test written for it:
66b7e12DestFromrecursion unboundedStack overflow.66b7e12UNCLOSED-MClines66b7e12MULTI-DOline66b7e12P-MISMATCH66b7e12linemarker66b7e1266b7e1266b7e1244c5e4944c5e4944c5e4944c5e4944c5e4944c5e49BAD-PROPERTIESline44c5e49f13d3faplus the later line-cap testf13d3faplus the later line-cap testf13d3faplus the later line-cap testf13d3faplus the later line-cap testf13d3faplus the later line-cap test1acac44/Dread without the null-as-absent helperA linear CMap lookup passed the first complexity test, because with the wide range first the
flattened table has a single segment. The test added in
1bdd0ceputs the wide range last; with alinear lookup it fails after about 15 seconds. The
1bdd0cecommit message says the table has about100,000 segments; the measured count is 50,002, and the squash message does not repeat the claim.
GC.GetAllocatedBytesForCurrentThreadover oneDumpof a 4,000-code show string measured 138,360bytes against 123,936 for 400 codes, the same in Debug and in Release.
The original five mutation proofs were run on
66b7e12and were not repeated on the final head.Not verified
does not authenticate throws
PdfPasswordException. Neither case is tested.dates, but the Verify comparison on the first CI run is the check.
Review history
The brief was reviewed twice before implementation. After it, four rounds reviewed the branch, each
by independent reviewers: round 1 on
150294e, round 2 on66b7e12, round 3 on1bdd0ceandround 4 on
3e16906. Round 1 found two kinds of problem: a crash on a self-referencing destinationdictionary and several things the dump silently skipped. Round 2 found that the round-1 fixes covered
the sites named and not their siblings, so output charging, string escaping, problem counting and
integer reading were each made structural. Round 3 raised a decode that built a whole string before
capping it, and a missing test for uncharged check lines. Round 4 found no HIGH and eight MEDIUM
findings, almost all comment and documentation corrections. After round 3 the orchestrator decided
that the dumper is a test oracle for trusted input, so pathological-cost inputs are documented as out
of scope instead of hardened further. That decision is pending the maintainer's confirmation. The
branch's commits are meant to be squashed; the squash message is drafted separately.