Skip to content

Commit ad4351a

Browse files
committed
Pass ActualText through to BDC properties in content stream
Screen readers read BDC properties from the content stream, not just the structure tree. When ActualText is set on a structure element, include it in the BDC marked content properties so screen readers can use it as replacement text.
1 parent d6e686e commit ad4351a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/pdf/core/structure_tree.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ def mark_content(tag, struct_elem_ref: nil)
149149
@parent_tree_map[page_struct_parents][mcid] = elem_ref
150150

151151
# Emit BDC/EMC in content stream
152-
renderer.begin_marked_content_with_properties(tag, { MCID: mcid })
152+
bdc_props = { MCID: mcid }
153+
actual_text = renderer.deref(elem_ref)[:ActualText]
154+
bdc_props[:ActualText] = actual_text if actual_text
155+
renderer.begin_marked_content_with_properties(tag, bdc_props)
153156
yield if block_given?
154157
renderer.end_marked_content
155158
end

0 commit comments

Comments
 (0)