Class: Rpdf2txt::CMap

Inherits:
Stream show all
Defined in:
lib/rpdf2txt/object.rb

Constant Summary

Constants inherited from Stream

Stream::BT_PATTERN, Stream::ET_PATTERN, Stream::FAIL_PTRN

Instance Attribute Summary collapse

Attributes inherited from PdfObject

#attributes, #decoder, #oid, #src

Instance Method Summary collapse

Methods inherited from Stream

#append, #decode_raw_stream, #decoded_stream, #decoded_stream=, #extract_horizontal_rules, #extract_nontext_objects, #extract_text_objects, #flate_decode, #lzw_decode, #raw_stream, #to_cmap

Methods inherited from PdfObject

#_parse_attributes, #build_tree, #catalogue_object, #decoded_stream, #extract_attribute_stream, #parse_attributes, #revision_id

Constructor Details

#initialize(*args) ⇒ CMap

Returns a new instance of CMap.



1032
1033
1034
1035
1036
# File 'lib/rpdf2txt/object.rb', line 1032

def initialize(*args)
	@map = {}
	super
	parse_cmap()
end

Instance Attribute Details

#mapObject

Returns the value of attribute map.



1031
1032
1033
# File 'lib/rpdf2txt/object.rb', line 1031

def map
  @map
end

Instance Method Details

#to_utf8(txt) ⇒ Object



1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
# File 'lib/rpdf2txt/object.rb', line 1037

def to_utf8(txt)
  if(@map.nil?)
    txt
  elsif(txt.is_a?(Integer))
    @map[txt]
  else
    txt.unpack('C*').collect { |byte| 
      @map.fetch(byte, byte) }.pack('U*')
  end
end