Method: HexaPDF::Content::Canvas#marked_content_sequence

Defined in:
lib/hexapdf/content/canvas.rb

#marked_content_sequence(tag, property_list: nil) ⇒ Object

:call-seq:

canvas.marked_content_sequence(tag, property_list: nil)               -> canvas
canvas.marked_content_sequence(tag, property_list: nil) { block }     -> canvas

Inserts a marked-content sequence, optionally associated with a property list. Returns self.

A marked-content sequence is used to identify a sequence of complete graphics objects in the content stream for later use by other applications, e.g. for tagged PDF. The symbol tag is used to uniquely identify the role of the marked-content sequence and should be registered with ISO to avoid conflicts.

The optional property_list argument can either be a valid PDF dictionary or a symbol referencing an already used property list in the resource dictionary’s /Properties dictionary.

If invoked without a block, a corresponding call to #end_marked_content_sequence must be done. Otherwise the marked-content sequence automatically ends when the block is finished.

Although the PDF specification would allow using marked-content sequences inside text objects, this is prohibited in HexaPDF.

Examples:

canvas.marked_content_sequence(:Divider)
# Other instructions
canvas.end_marked_content_sequence

canvas.marked_content_sequence(:Divider, property_list: {Key: 'value'}) do
  # Other instructions
end

See: PDF2.0 s14.6, #end_marked_content_sequence, #marked_content_point



2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
# File 'lib/hexapdf/content/canvas.rb', line 2505

def marked_content_sequence(tag, property_list: nil)
  raise_unless_at_page_description_level
  if property_list
    property_list = resources.property_list(property_list) if property_list.kind_of?(Symbol)
    invoke2(:BDC, tag, resources.add_property_list(property_list))
  else
    invoke1(:BMC, tag)
  end
  if block_given?
    yield
    end_marked_content_sequence
  end
  self
end