Class: HexaPDF::Task::Optimize::SerializationProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/task/optimize.rb

Overview

This processor is used when compressing pages.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&error_block) ⇒ SerializationProcessor

:nodoc:



280
281
282
283
284
285
# File 'lib/hexapdf/task/optimize.rb', line 280

def initialize(&error_block) #:nodoc:
  @result = ''.b
  @serializer = HexaPDF::Serializer.new
  @used_references = []
  @error_block = error_block
end

Instance Attribute Details

#resultObject (readonly)

:nodoc:



275
276
277
# File 'lib/hexapdf/task/optimize.rb', line 275

def result
  @result
end

#used_referencesObject (readonly)

Contains all found references



278
279
280
# File 'lib/hexapdf/task/optimize.rb', line 278

def used_references
  @used_references
end

Instance Method Details

#process(op, operands) ⇒ Object

:nodoc:



287
288
289
290
291
292
293
294
# File 'lib/hexapdf/task/optimize.rb', line 287

def process(op, operands) #:nodoc:
  @result << HexaPDF::Content::Operator::DEFAULT_OPERATORS[op].
    serialize(@serializer, *operands)
  @used_references << operands[0] if op == :Do
rescue StandardError => e
  @error_block.call("Invalid content stream operation found: " \
                    "#{op}#{operands.inspect} (#{e.message})")
end