Repository navigation
Tagged PDF: PDF/UA-1 and PDF/A-3a from the boxes' roles - #114
Merged
Merged
Conversation
pdf: :ua and pdf_a: :a tag the native boxes from their roles: a structure tree in reading order, marked content per page, artifacts for headers, footers, backgrounds, borders and repeated table headers. What breaks a rule raises where it is written. CI installs veraPDF, which checks PDF/A, PDF/UA and tagged documents. Part of #76. Assisted-by: Claude Opus 5.5 [Claude Code]
Marks are written at the first thing drawn, so a box moving to the next page leaves no empty sequence or decoration behind. Tables in a figure or a cell, list nesting, imported pages' fonts, page-create callbacks and a cell drawn alone are tagged or refused. The default style's font is looked up when first used, and style no longer places a waiting box. Assisted-by: Claude Opus 5.5 [Claude Code]
…exts A decoration moved beneath an artifact's content is written as an artifact of its own. Annotations, an alt that is blank or not text, and a lang that is not a language tag raise. The fuzzer turns one stack in three into an artifact and catches content painted outside any sequence. Assisted-by: Claude Opus 5.5 [Claude Code]
A box's alt must be text and its lang a language tag, tagged or not; the document's lang too when tagged. A page with marked content of its own cannot go into a tagged document: its MCIDs would point at a structure tree left behind. Assisted-by: Claude Opus 5.5 [Claude Code]
TruffleRuby skipped the module prepended from Node.inherited, so tagged documents raised there. Containers and the document now call flow_tagged and paint_tagged, which cost one tagged? check when untagged. Assisted-by: Claude Opus 5.5 [Claude Code]
czj
added a commit
that referenced
this pull request
Nov 19, 2026
Gamba.combine copied a page without /Resources as it was, even though ISO 32000-1 requires them, empty or inherited. qpdf 12.4 now warns about such a page and repairs it, so `test_combined_pages_never_write_infinite_numbers` fails on a Mac with current Homebrew tools, and in CI once its package cache refreshes (it does on #114). A copied page with no resources of its own or inherited now gets an empty dictionary, as pages Gamba draws already do. - **Only invalid sources change**: a page that has resources, its own or inherited, is copied as before. <details><summary>Proof</summary> - With qpdf 12.4.2 and MuPDF 1.28.6: `test_combined_pages_never_write_infinite_numbers` fails on main and passes here. - Full `rake test` with the corpus fetched: 1387 runs, 0 failures. RuboCop clean. </details> Co-authored-by: Clément Joubert <[email protected]>
LibreOffice writes /P<</MCID 0>>BDC with no space before the operator, which the imported page check let through. A blank info Title passed the PDF/UA title check. Assisted-by: Claude Opus 5.5 [Claude Code]
…oad every box with Layout The review of 860db65 found BDC missed before a delimiter (BDC[(a)]TJ) and Title: false accepted. Gamba::Layout loaded alone left Layout::Table undefined, which failed a roles test when it ran first (also on main). Assisted-by: Claude Opus 5.5 [Claude Code]
… from layout A title in ISO-8859-1 raised an encoding error, and titles or alts of only invisible characters passed. Gamba::Layout pointed at the document file broke requiring native/layout after gamba: layout.rb requires the table and the bands instead. Assisted-by: Claude Opus 5.5 [Claude Code]
…read as binary scrub turned invalid bytes into a visible replacement character, and a binary alt that converted to nothing was refused even in untagged documents. Assisted-by: Claude Opus 5.5 [Claude Code]
…where given 524c772 checked a binary alt as UTF-8 but kept the bytes, which then failed to serialize in tagged documents. Assisted-by: Claude Opus 5.5 [Claude Code]
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.
A screen reader reads the PDFs Gamba writes glyph by glyph, in drawing order: no headings, no tables, no language. #110 gave every native box a role; nothing read them yet.
pdf: :uawrites PDF/UA-1 andpdf_a: :aPDF/A-3a, alone or together, tagging the native boxes from their roles. Part of #76: the Prawn API'stagandartifactblocks,ActualTextfor ligatures and the cost on the benchmarks page come next.alt, and tables with column header cells, in the order boxes are placed. A paragraph or a table across pages stays one element;lang:on any box sets its language.alt, a list item outside a list, anything drawn throughdocument.prawn, and underpdf: :uanolang, no title or a skipped heading level, raisePdfUaViolation(PdfAViolationunderpdf_a: :aalone). In both modes, the default style's font is also the document's, looked up when first used, since Helvetica cannot be embedded.pdf_a:now accepts onlytrue,false,nil,:aand:b, and raises on anything else./OC … BDC), and text that happens to containBDCorBMCas a word, count as marked content.flow_tagged,paint_tagged), onetagged?check when untagged. A module prepended to every box class did it at first, and TruffleRuby skipped it.main, and tagged pages are pixel-identical to untagged ones with the same default font.Proof
test/tagging_test.rb: veraPDF passesua1and3aon a report (headings, a paragraph and a decorated stack across pages, lists, a figure, an 80-row table, a header, a French paragraph) under each mode and both together, and on the threebench/nativedocuments tagged. qpdf reads back the structure tree, one paragraph and one table across pages with its header once, balanced marked content and MCIDs matching the ParentTree on every page, and the catalog and XMP. MuPDF renders tagged and untagged pages identically, also when a decorated stack moves to the next page before drawing. Tables in a figure and in a cell, and each raised rule, are covered too.ua1.main.bench/native, median of 15, no JIT then YJIT: report 385 / 303 ms onmainagainst 388 / 309 ms here; catalog with YJIT interleaved 5 times 251 against 262 ms, within the noise of either side (237 to 278 ms). Same bytes, +0.1 % allocations (thelangslot).test_combined_pages_never_write_infinite_numbersfailed here with the newer qpdf this workflow change pulled in; Combined pages always name their resources #115 fixed that onmain, merged into this branch. RuboCop and the highlighted docs are clean.