Module: Prawn::Accessibility::MarkedContent Private

Included in:
StructureTree
Defined in:
lib/prawn/accessibility/marked_content.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Emits marked content operators (BMC/BDC/EMC) into a PDF content stream. These operators associate content with structure elements for accessibility (tagged PDF).

This is a mixin: the including object must respond to add_content(str) (as PDF::Core::Renderer does). It therefore needs no changes to any pdf-core class — StructureTree includes it and forwards add_content to the renderer.

Instance Method Summary collapse

Instance Method Details

#begin_marked_content(tag) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Begin a marked content sequence with no properties.

Parameters:

  • tag (Symbol)

    structure type tag (e.g., :P, :Span, :Artifact)



20
21
22
# File 'lib/prawn/accessibility/marked_content.rb', line 20

def begin_marked_content(tag)
  add_content("/#{tag} BMC")
end

#begin_marked_content_with_properties(tag, properties = {}) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Begin a marked content sequence with properties (BDC operator).

Parameters:

  • tag (Symbol)

    structure type tag

  • properties (Hash) (defaults to: {})

    properties dict (typically includes :MCID)



29
30
31
32
# File 'lib/prawn/accessibility/marked_content.rb', line 29

def begin_marked_content_with_properties(tag, properties = {})
  props = PDF::Core.pdf_object(properties, true)
  add_content("/#{tag} #{props} BDC")
end

#end_marked_contentvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

End a marked content sequence.



37
38
39
# File 'lib/prawn/accessibility/marked_content.rb', line 37

def end_marked_content
  add_content('EMC')
end

#marked_content_sequence(tag) { ... } ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Wrap a block in a marked content sequence (BMC/EMC).

Parameters:

  • tag (Symbol)

    structure type tag

Yields:

  • content to wrap



46
47
48
49
50
# File 'lib/prawn/accessibility/marked_content.rb', line 46

def marked_content_sequence(tag)
  begin_marked_content(tag)
  yield if block_given?
  end_marked_content
end

#marked_content_sequence_with_properties(tag, properties = {}) { ... } ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Wrap a block in a marked content sequence with properties (BDC/EMC).

Parameters:

  • tag (Symbol)

    structure type tag

  • properties (Hash) (defaults to: {})

    properties dict

Yields:

  • content to wrap



58
59
60
61
62
# File 'lib/prawn/accessibility/marked_content.rb', line 58

def marked_content_sequence_with_properties(tag, properties = {})
  begin_marked_content_with_properties(tag, properties)
  yield if block_given?
  end_marked_content
end