Class: HexaPDF::Task::PDFA::CIDCollector

Inherits:
Content::Processor show all
Defined in:
lib/hexapdf/task/pdfa.rb

Overview

Processes the contents of a stream and collects the CIDs for each composite font.

Constant Summary

Constants inherited from Content::Processor

Content::Processor::OPERATOR_MESSAGE_NAME_MAP

Instance Attribute Summary collapse

Attributes inherited from Content::Processor

#graphics_object, #graphics_state, #operators, #resources

Instance Method Summary collapse

Methods inherited from Content::Processor

#process

Constructor Details

#initializeCIDCollector

:nodoc:



163
164
165
166
# File 'lib/hexapdf/task/pdfa.rb', line 163

def initialize(*) # :nodoc:
  super
  @map = Hash.new {|h, k| h[k] = Set.new }
end

Instance Attribute Details

#mapObject (readonly)

The mapping from the composite font’s descendant font to the set of used CIDs.



161
162
163
# File 'lib/hexapdf/task/pdfa.rb', line 161

def map
  @map
end

Instance Method Details

#show_text(data) ⇒ Object Also known as: show_text_with_positioning

:nodoc:



168
169
170
171
172
173
174
175
176
# File 'lib/hexapdf/task/pdfa.rb', line 168

def show_text(data) # :nodoc:
  font = graphics_state.font
  return unless font[:Subtype] == :Type0 && font.descendant_font[:Subtype] == :CIDFontType2

  Array(data).each do |item|
    next if item.kind_of?(Numeric)
    @map[font.descendant_font].merge(font.decode(item))
  end
end