Repository navigation
Fix PDF/UA-1 conformance defects found auditing #325 - #389
Merged
Merged
Conversation
…' /ID ISO 32000-1 Table 344 makes /Headers an array of byte strings, each the /ID of a TH. They were written as names, which a reader matching them to the TH's /ID string does not find. veraPDF does not look at /Headers, so this showed only by hand. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An element's /K listed its children first and its own marked content after them. A link or a span with a lang is opened when its tag is read, before the text of its paragraph is drawn, so "Claim<a>1</a>." was read as "1 Claim ." (Matterhorn 09-001). Marked content is numbered as it is drawn, so the writer now puts each child after the parent's content drawn before it, and a child with no content after the content its parent had when it was added. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Every Form element was made when the widgets were written and added to the end of the Document, so a screen reader met all the fields after the last paragraph, far from their labels (Matterhorn 09-001). The element is now made when the widget is drawn, inside the element around it, and the widget joins it when written. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…body The rows a table repeats at each page break were tagged as more content of the same TH and TD, so a screen reader read the header once per page. They are now artifacts. A <tfoot> written before <tbody>, as HTML 4 asked, was also read before the body; the TFoot is now written after the last TBody. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ption <figure> and role="figure" were tagged Figure however they were named, so a figure holding an <img alt> and a <figcaption> left a Figure with no /Alt around another Figure, which veraPDF rejects (ISO 14289-1 §7.3, Matterhorn 13-004). Without aria-label or aria-labelledby the figure is now a Div. A block with role="img" and no name throws, as an <img> without alt does, and is a Div under PDFUAauto. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An <img> without alt that role="presentation", role="none" or aria-hidden="true" marks as decorative threw in strict mode instead of being drawn as an artifact. An inline <svg> lost its role and aria-* attributes when it was turned into an <img>, so an <svg aria-label> threw for a missing alt, and under PDFUAauto its name was dropped. Those attributes now go across with its class. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PDF/A allows only the XMP schemas it names and those declared in a pdfaExtension schema (ISO 19005-1 §6.7.8, ISO 19005-2 §6.6.2.3.2), so a document with PDFA and PDFUA both on failed PDF/A over its pdfuaid:part. The schema is now declared when both are on; a PDF/A-2b document now passes both ua1 and 2b. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ts widgets leave empty Importing a tagged page copied only /Alt, /ActualText and /Lang, so its header cells lost /Scope and its cells their spans; importing mPDF's own PDF/UA output with a table failed veraPDF (7.5-1, 7.2-42). /Scope, /ColSpan, /RowSpan, /ListNumbering and /Placement now come across. A widget is not imported, and an imported link is given an element of its own, so the copied Form or Link element was left with nothing: veraPDF rejected the Form (7.18.4-2) and strict mode threw for the Link. Such an element is now dropped. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
FPDI hands over an imported link's own entries, which the writer added after its own /Contents and /F, so under PDF/UA both keys appeared twice in the one annotation dictionary. The source's /Contents is now kept in place of the generated one, and its /F gives way to the flags PDF/A and PDF/UA need. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… link Two paragraphs list their own text before the Link and Figure inside them; the XMP document id, a hash of the output, changes with them. The pages are the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
BlockTag and Img each tested role="none"/"presentation" and aria-hidden, and already differed over trimming; StructType::isPresentational() now answers for both. Form and the annotation writer made an empty Form or Link by opening, reading and closing; StructureTree::addLeaf() does it. The importer reads /A with normaliseKidsToArray() in one loop, the writer skips the reading-order merge where there is nothing to merge, and an inline SVG's ARIA attributes are read only under PDF/UA. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 23, 2026
Static form field values are marked as artifacts under PDF/UA, so screen readers never get them
#404
Open
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.
Fixes for defects found while auditing #325's PDF/UA-1 output. I generated about 70 HTML documents and 14 direct-API documents with
PDFUAon (headings, lists, tables across pages, images, SVG, links, forms, TOC, languages, RTL, CJK and Indic, watermarks, backgrounds, PDF/A), and re-imported each one with mPDF's own importer. Every document went through veraPDF 1.30--flavour ua1, and the ones veraPDF can't judge were checked by hand.Defects fixed
Each defect is its own commit, with tests.
/Headerswritten as names. ISO 32000-1 Table 344 makes it an array of byte strings matching the TH/ID, but it was written as[/col1]. veraPDF doesn't check this (bogus IDs pass too). To reproduce:<table><tr><th id="a">A</th></tr><tr><td headers="a">1</td></tr></table>./Klisted its children before its own MCIDs, so<p>Claim<sup><a href="#fn">1</a></sup>.</p>read as "1 Claim ." and<p>Hello <span lang="de">Guten Tag</span></p>read as "Guten Tag Hello". Kids are now merged by drawing order.<thead>gave its TH one MCID per page, so the header was read on every page. Repeats are now artifacts. A<tfoot>written before<tbody>was also read before the body; it is now written after the last TBody.<figure>without/Alt(veraPDF 7.3-1).<figure><img alt="x"><figcaption>…</figcaption></figure>and<div role="figure">gave a Figure with no/Alt. An unnamed figure is now a Div. An unnamedrole="img"block throws, or becomes a Div underPDFUAauto.<img role="presentation">(orrole="none"oraria-hidden="true") without alt threw in strict mode.<svg aria-label="…">lost its attributes when turned into an<img>and threw for a missing alt.pdfuaid:partwas not declared in apdfaExtensionschema (ISO 19005-1 §6.7.8, 19005-2 §6.6.2.3.2; veraPDF 1b 6.7.9-2/-3, 2b 6.6.2.3.1-1/-2).PDFA+PDFAversion => '2-B'+PDFUAnow passes bothua1and2b./Alt,/ActualTextand/Langwere copied./Scope) and 7.2-42 (lost/ColSpan)./Scope,/ColSpan,/RowSpan,/ListNumberingand/Placementare now copied, and Form and Link elements left empty are dropped./Contentsand/Ftwice in one annotation dictionary. The source's/Contentsis kept, and the host's/Fis written.A final commit pulls out
StructType::isPresentational()andStructureTree::addLeaf()so BlockTag, Img, Form and the annotation writer share them.Found but not fixed (for discussion)
Cell(),MultiCell(),Write(),Text(),WriteText(),WriteCell(),CircularText(),Shaded_box(),Rect()andLine()fail veraPDF 7.1-3 ($mpdf->WriteHTML('<h1>x</h1>'); $mpdf->Cell(40, 10, 'Text');).AutosizeText(),Image()andWriteFixedPosHTML()are fine. To fix this, someone has to decide what each call is tagged as (a P per call? graphics as artifacts?).PDFUAauto. It only warns, and the output fails 7.1-9. It could fall back to the first heading or an HTML<title>.useActiveFormsoff, a text input's printed value and a checkbox's state are artifacts, so the information is hidden from assistive technology./ActualTextor/ReversedChars. pdftotext readsمرحبا بالعالمback with its words reversed.<a href><img alt="…"></a>puts the Figure beside the Link, not inside it, so the Link's only content is its annotation.[ ] Checkreads "Check, checkbox".gravitypdfin 7 files: Form, FpdiTrait, Mpdf, Protection, BaseWriter, FontWriter and MetadataWriter.gravitypdfhas since fixed the ToUnicode CMap for every document (The ToUnicode CMap of every CID font maps the whole two-byte space in a single bfrange, which may not cross a high-byte boundary #344/Write the ToUnicode CMap of a CID font in ranges that stay inside one high byte #362), which makes the PR's PDF/UA-onlyidentityRanges()redundant, and it moved encryption to AES-256.Verification
composer test(PHP 8.5,CI=1, Imagick + Ghostscript): 3732 tests OK, 71 skipped (the veraPDF group withoutVERAPDF_BIN, plus the usual generator skips).VERAPDF_BIN=… phpunit --group=verapdf: 66 of 66 pass. Three are new: figure with caption, PDF/A-2b + UA, and tagged import of a table, form and link.composer test -- --group=snapshot: 86 of 86 pass. Thepdfuafixture is refreshed: two paragraphs now list their own text before their Link or Figure, and the XMP document id changes with the output. The pages are identical.composer csclean. PHPStan 2 level 2 clean. Changed files lint under PHP 5.6.🤖 Generated with Claude Code