Skip to content

Commit 90b72b9

Browse files
craigmcnamaraclaude
andcommitted
Add ActualText attribute support for structure elements
Allows setting /ActualText on structure elements so screen readers announce replacement text instead of reading visual characters literally (e.g., "required" instead of "asterisk" for *, "selected" for X). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cd1f310 commit 90b72b9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

lib/pdf/core/structure_tree.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def allocate_mcid
6666
# @param tag [Symbol] structure type (e.g., :P, :H1, :Table, :TD)
6767
# @param attributes [Hash] additional attributes for the structure element
6868
# @option attributes [String] :Alt alternative text (for Figure, Formula)
69+
# @option attributes [String] :ActualText replacement text for screen
70+
# readers (e.g., "required" instead of reading "*")
6971
# @option attributes [String] :Lang language tag
7072
# @option attributes [Symbol] :Scope TH scope (:Column, :Row, :Both)
7173
# @return [PDF::Core::Reference] the structure element reference
@@ -80,6 +82,7 @@ def add_element(tag, attributes = {})
8082
}
8183

8284
elem_data[:Alt] = attributes[:Alt] if attributes[:Alt]
85+
elem_data[:ActualText] = attributes[:ActualText] if attributes[:ActualText]
8386
elem_data[:Lang] = attributes[:Lang] if attributes[:Lang]
8487

8588
if attributes[:Scope]

0 commit comments

Comments
 (0)