Class: Pdfrb::Content::Operator::BeginInlineImage

Inherits:
Base
  • Object
show all
Defined in:
lib/pdfrb/content/operators/inline_image.rb

Overview

Inline image operators (s8.9.7). Inline images embed raw image data directly in the content stream, framed by BI ... ID ... EI. They're an alternative to /XObject /Image for one-shot images: smaller overhead per image, no /Resources entry needed, but the bytes live in the content stream so they can't be reused.

The Parser detects BI ... ID ... EI and yields a single BeginInlineImage invocation with the parsed image Hash as the operand. The invoke hook calls Processor#inline_image.

Class Method Summary collapse

Methods inherited from Base

register

Class Method Details

.invoke(processor, image = nil) ⇒ Object



29
30
31
# File 'lib/pdfrb/content/operators/inline_image.rb', line 29

def invoke(processor, image = nil)
  processor.inline_image(image) if image
end

.nameObject



18
# File 'lib/pdfrb/content/operators/inline_image.rb', line 18

def name; "BI"; end

.serialize(serializer, **dict) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/pdfrb/content/operators/inline_image.rb', line 20

def serialize(serializer, **dict)
  buf = +"BI\n"
  dict.each do |k, v|
    buf << serializer.serialize(k) << " " << serializer.serialize(v) << "\n"
  end
  buf << "ID\n"
  buf
end