Module: HexaPDF::DictionaryFields::PDFByteStringConverter

Defined in:
lib/hexapdf/dictionary_fields.rb

Overview

Converter module for binary string fields to automatically convert a string into binary encoding.

Class Method Summary collapse

Class Method Details

.additional_typesObject

:nodoc:



258
259
260
# File 'lib/hexapdf/dictionary_fields.rb', line 258

def self.additional_types
  String
end

.convert(str, _type, _document) ⇒ Object

Converts the string into binary encoding, assuming it is a non-binary string. Otherwise returns nil.



264
265
266
267
# File 'lib/hexapdf/dictionary_fields.rb', line 264

def self.convert(str, _type, _document)
  return if !str.kind_of?(String) || str.encoding == Encoding::BINARY
  str.force_encoding(Encoding::BINARY)
end

.usable_for?(type) ⇒ Boolean

This converter is usable if the type is PDFByteString.

Returns:



253
254
255
# File 'lib/hexapdf/dictionary_fields.rb', line 253

def self.usable_for?(type)
  type == PDFByteString
end