Class: HexaPDF::Content::Operator::SetGraphicsStateParameters

Inherits:
BaseOperator
  • Object
show all
Defined in:
lib/hexapdf/content/operator.rb

Overview

Implementation of the ‘gs’ operator.

Note: Only parameters supported by the GraphicsState/TextState classes are assigned, the rest are ignored!

See: PDF2.0 s8.4.4

Instance Attribute Summary

Attributes inherited from BaseOperator

#name

Instance Method Summary collapse

Constructor Details

#initializeSetGraphicsStateParameters

Creates the operator.



315
316
317
# File 'lib/hexapdf/content/operator.rb', line 315

def initialize
  super('gs')
end

Instance Method Details

#invoke(processor, name) ⇒ Object

:nodoc:



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/hexapdf/content/operator.rb', line 319

def invoke(processor, name) #:nodoc:
  dict = processor.resources.ext_gstate(name)

  ops = processor.operators
  ops[:w].invoke(processor, dict[:LW]) if dict.key?(:LW)
  ops[:J].invoke(processor, dict[:LC]) if dict.key?(:LC)
  ops[:j].invoke(processor, dict[:LJ]) if dict.key?(:LJ)
  ops[:M].invoke(processor, dict[:ML]) if dict.key?(:ML)
  ops[:d].invoke(processor, *dict[:D]) if dict.key?(:D)
  ops[:ri].invoke(processor, dict[:RI]) if dict.key?(:RI)

  # No content operator exists for the following parameters
  gs = processor.graphics_state
  gs.stroke_adjustment = dict[:SA] if dict.key?(:SA)
  gs.blend_mode = dict[:BM] if dict.key?(:BM)
  gs.stroke_alpha = dict[:CA] if dict.key?(:CA)
  gs.fill_alpha = dict[:ca] if dict.key?(:ca)
  gs.alpha_source = dict[:AIS] if dict.key?(:AIS)
  gs.soft_mask = dict[:SMask] if dict.key?(:SMask)
  gs.text_knockout = dict[:TK] if dict.key?(:TK)
  if dict.key?(:Font)
    gs.font = processor.resources.document.deref(dict[:Font][0])
    gs.font_size = processor.resources.document.deref(dict[:Font][1])
  end
end

#serialize(serializer, name) ⇒ Object

:nodoc:



345
346
347
# File 'lib/hexapdf/content/operator.rb', line 345

def serialize(serializer, name) #:nodoc:
  "#{serializer.serialize_symbol(name)} gs\n"
end