lib/combine_pdf/renderer.rb in combine_pdf-0.2.30 vs lib/combine_pdf/renderer.rb in combine_pdf-0.2.31

- old
+ new

@@ -19,11 +19,11 @@ elsif object.is_a?(Symbol) return format_name_to_pdf object elsif object.is_a?(Array) return format_array_to_pdf object elsif object.is_a?(Fixnum) || object.is_a?(Float) || object.is_a?(TrueClass) || object.is_a?(FalseClass) - return object.to_s + ' ' + return object.to_s elsif object.is_a?(Hash) return format_hash_to_pdf object else return '' end @@ -31,15 +31,15 @@ STRING_REPLACEMENT_HASH = { "\x0A" => '\\n', "\x0D" => '\\r', "\x09" => '\\t', "\x08" => '\\b', - "\xFF" => '\\f', + "\x0C" => '\\f', # form-feed (\f) == 0x0C "\x28" => '\\(', "\x29" => '\\)', "\x5C" => '\\\\' }.dup 32.times { |i| STRING_REPLACEMENT_HASH[i.chr] ||= "\\#{i}" } - (256 - 128).times { |i| STRING_REPLACEMENT_HASH[(i + 127).chr] ||= "\\#{i + 127}" } + (256 - 127).times { |i| STRING_REPLACEMENT_HASH[(i + 127).chr] ||= "\\#{i + 127}" } def format_string_to_pdf(object) # object.force_encoding(Encoding::ASCII_8BIT) if !object.match(/[^D\:\d\+\-\Z\']/) # if format is set to Literal and string isn't a date ('(' + ([].tap { |out| object.bytes.to_a.each { |byte| STRING_REPLACEMENT_HASH[byte.chr] ? (STRING_REPLACEMENT_HASH[byte.chr].bytes.each { |b| out << b }) : out << byte } }).pack('C*') + ')').force_encoding(Encoding::ASCII_8BIT)