-
Notifications
You must be signed in to change notification settings - Fork 4.8k
feat: add PDF/UA (Universal Accessibility) support #3930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
heikofolkerts
wants to merge
9
commits into
parallax:master
Choose a base branch
from
heikofolkerts:feature/pdfua-pr-clean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: add PDF/UA (Universal Accessibility) support #3930
heikofolkerts
wants to merge
9
commits into
parallax:master
from
heikofolkerts:feature/pdfua-pr-clean
Conversation
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
This commit adds comprehensive PDF/UA support to jsPDF, enabling the
creation of accessible PDFs that conform to ISO 14289-1.
Features:
- Structure tree with semantic elements (H1-H6, P, Span, Link, etc.)
- Alt text for images (Figure element)
- Table accessibility with header scope (TH, TD, TR)
- Lists with proper structure (L, LI, Lbl, LBody)
- Form field accessibility (AcroForm with structure elements)
- Font embedding with Atkinson Hyperlegible (accessibility-focused font)
- XMP metadata with PDF/UA identification
- Document language and structure tagging
- Artifacts for headers, footers, and decorative content
- TOC structure with bookmarks
- Additional semantic elements: Quote, Code, Note, Caption, Formula
- CJK annotations with Ruby/Warichu support
- DocumentFragment and Aside (PDF 2.0) support
- Accessible annotations (Text/FreeText)
API Usage:
```javascript
const doc = new jsPDF({ pdfUA: true });
doc.setDocumentTitle('Accessible Document');
doc.setLanguage('en-US');
doc.beginStructureElement('H1');
doc.text('Heading', 20, 20);
doc.endStructureElement();
```
Tests:
- Unit tests in test/specs/pdfua.spec.js
- Feature test suites in tests/pdfua/
- Comprehensive showcase document
Documentation:
- Getting started guide
- API reference
- Structure elements reference
- Examples
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix K-Array ordering to preserve correct reading sequence - Added kItems array to track MCIDs and children in order - Modified addMCID and addChild to maintain order - Updated K-array generation to use ordered kItems - Fixed beginStructureElement to use addChild method - Showcase document optimizations for PAC compliance - Consistent subchapter numbering (3.1, 3.2, 7.1-7.3, etc.) - Footnote references placed at correct terms - Annotations as block-level elements (not inline in P) - Removed off-page content for footnote announcements - All PAC warnings resolved, veraPDF validation passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Run prettier --write to fix code style issues that were causing the CI lint check to fail. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Resolve merge conflicts in dist/ files by accepting upstream versions. Will rebuild to incorporate PDF/UA changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Author
|
Hi maintainers, I've just updated this PR to:
All local tests pass (495 specs, 0 failures) and the Snyk security check has passed. Could you please approve the CI workflow run so the full test suite can execute? The workflow is waiting for approval here: Thank you! |
The link test suite was using separate text() and link() calls, which didn't properly connect the link annotation to the Link structure element. Changed to use textWithLink() which correctly associates the annotation with the structure tree. All 5 link tests now pass veraPDF PDF/UA-1 validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Generated test PDFs should not be tracked in version control. They are regenerated by running the test suites. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.
Summary
This PR adds comprehensive PDF/UA (Universal Accessibility) support to jsPDF, enabling the creation of accessible PDF documents that comply with ISO 14289-1 (PDF/UA-1).
Key Features
new jsPDF({ pdfUA: true })New API Methods
Files Changed
src/jspdf.js- PDF/UA initialization, font loading, API integrationsrc/modules/structure_tree.js- Core structure tree implementation (new)src/modules/pdfua_fonts.js- Atkinson Hyperlegible font data (new)src/modules/xmp_metadata.js- Enhanced XMP metadata for PDF/UAsrc/modules/annotations.js- Link annotation supportsrc/modules/acroform.js- Accessible form fieldstypes/index.d.ts- Complete TypeScript definitionsTesting
test/specs/pdfua.spec.jstests/pdfua/Documentation
Complete documentation in
docs/pdfua/:Backward Compatibility
{ pdfUA: true }optionTest plan
🤖 Generated with Claude Code