Repository navigation
Conversation
parsePdfBasics searched the raw file bytes for /MarkInfo, /StructTreeRoot, /Title, /Lang, BT, /FontFile and /ToUnicode. WeasyPrint and most current writers put the catalog, structure tree and Info dictionary in a compressed object stream (/Type /ObjStm) and compress the page content, so none of those markers appear in the raw bytes and a tagged PDF/UA file was reported as untagged, untitled, without language, text or fonts. Inflate FlateDecode object streams, content streams and form XObjects with node:zlib and search their contents along with the raw bytes. Images, fonts and other binary streams are skipped, and inflated output is capped at 50 MB. The CI scanner in .github/scripts/pdf-a11y-scan.mjs gets the same helper. Fixes Community-Access#297 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FDKaHBvCwNUbDLqsswZqqD
|
Thanks for this fix. I tested the branch and found one side effect: a bookmark title can now be read as the document title. To reproduce: a one-page PDF with no title in the Info dictionary and one bookmark called "Bookmark", saved by pdf-lib with its default object streams. const doc = await PDFDocument.create();
doc.addPage().drawRectangle({ width: 10, height: 10 });
const outlines = doc.context.obj({ Type: "Outlines" });
const outlinesRef = doc.context.register(outlines);
const item = doc.context.register(
doc.context.obj({ Title: PDFString.of("Bookmark"), Parent: outlinesRef }));
outlines.set(PDFName.of("First"), item);
outlines.set(PDFName.of("Last"), item);
doc.catalog.set(PDFName.of("Outlines"), outlinesRef);
await writeFile("graphics.pdf", await doc.save());On this branch (
On Expected: the title check passes only when the document itself has a title. This file has none. Cause: the title regex takes the first Possible fix: read |
What this changes and why
Fixes #297.
parsePdfBasicssearched the raw file bytes for/MarkInfo,/StructTreeRoot,/Title,/Lang,BT,/FontFileand/ToUnicode. WeasyPrint and most current writers put the catalog, structure tree and Info dictionary in a compressed object stream (/Type /ObjStm) and compress the page content, so a tagged PDF/UA file came back as untagged, with no title, language, text or fonts, and the user was told to OCR a document that already had real text.The scanner now inflates FlateDecode object streams, content streams and form XObjects with
node:zlib(no new dependency) and searches their contents along with the raw bytes. Images, embedded fonts, cross-reference streams and other binary streams are skipped so their bytes cannot match a marker by accident, a stream that does not inflate is skipped, and inflated output is capped at 50 MB per file..github/scripts/pdf-a11y-scan.mjshad the same raw-bytes approach and gets the same helper.Tested:
pdf_variant="pdf/ua-1"):scan_pdf_documentwent from 6 findings to none, and the expanded copy still has none. The CI script went from 6 errors to none on the same file.mcp-server/server-core.test.js: a tagged PDF built with its objects in a compressed object stream and compressed page content (fails onmainwith thepdf-tagged,pdf-structure-tree,pdf-title,pdf-language,pdf-text-contentandpdf-fontsfindings, passes with the fix), and an untagged PDF with a damaged Flate stream that must still be reported.npm run verify: 22 of 22 checks pass.npm run verify:releasepasses.Accessibility checklist
Checks
npm run verifypasses (it includes the Markdown accessibility linter and markdownlint)Documentation and skill text (any change to Markdown, a skill or a report template)
The only Markdown change is one CHANGELOG entry.
Findings and guidance (skill changes)
N/A: no skill changes, and no finding wording changed.
Anything with a user interface (generated HTML,
example/, a dashboard)N/A
Terminal and MCP output (the installer, scripts, hooks, MCP tools, report wording)
Dependencies
N/A: no dependency added.
Release
N/A: no version or release files changed.
Accessibility notes
Only Flate is inflated. A stream behind another filter (for example ASCII85 then Flate) is still searched only as raw bytes, as before.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FDKaHBvCwNUbDLqsswZqqD