Add high-level accessibility API for tagged PDF generation#1391
Open
craigmcnamara wants to merge 5 commits intoprawnpdf:masterfrom
Open
Add high-level accessibility API for tagged PDF generation#1391craigmcnamara wants to merge 5 commits intoprawnpdf:masterfrom
craigmcnamara wants to merge 5 commits intoprawnpdf:masterfrom
Conversation
Adds Prawn::Accessibility module providing structure(), structure_container(),
artifact(), heading(), paragraph(), and figure() methods for creating
Section 508 compliant tagged PDFs.
Usage:
pdf = Prawn::Document.new(marked: true, language: 'en-US')
pdf.heading(1, 'Title')
pdf.paragraph('Body text.')
pdf.artifact { pdf.text 'Page 1' }
New options on Prawn::Document.new:
- marked: true — enables tagged PDF mode
- language: 'en-US' — sets document language in Catalog
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests that ActualText is properly passed through to structure elements, useful for screen reader replacement text on symbolic characters like * (required) and X (selected checkbox). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Adds
Prawn::Accessibilitymodule providing a user-friendly API for generating Section 508 compliant tagged PDFs.New document options:
marked: true— enables tagged PDF mode (structure tree, marked content)language: 'en-US'— sets/Langon the CatalogNew methods on
Prawn::Document:tagged?— check if document is in tagged modestructure(tag, attributes, &block)— wrap content in a structure element with BDC/EMCstructure_container(tag, attributes, &block)— container element for nesting (children tag themselves)artifact(type:, &block)— mark decorative content (footers, borders) excluded from screen readersheading(level, text, options)— H1-H6 convenienceparagraph(text, options, &block)—<P>conveniencefigure(alt_text:, &block)—<Figure>with/AltSupported attributes:
:Alt,:ActualText,:Lang,:ScopeDependency: This PR depends on prawnpdf/pdf-core#67 being merged first. The new accessibility specs require the
marked:option andStructureTreeclass added in that PR. Test failures in CI forreleaseandedgematrix variants are expected until pdf-core#67 is merged and available.See also companion PR for prawn-table#164.
Addresses prawnpdf/prawn-table#78
Test plan
releaseandedgetests will pass once pdf-core#67 is merged🤖 Generated with Claude Code