lib/combine_pdf/renderer.rb in combine_pdf-1.0.5 vs lib/combine_pdf/renderer.rb in combine_pdf-1.0.6
- old
+ new
@@ -40,10 +40,10 @@
32.times { |i| STRING_REPLACEMENT_HASH[i.chr] ||= "\\#{i}" }
(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
+ 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)
else
# A hexadecimal string shall be written as a sequence of hexadecimal digits (0–9 and either A–F or a–f)
# encoded as ASCII characters and enclosed within angle brackets (using LESS-THAN SIGN (3Ch) and GREATER- THAN SIGN (3Eh)).
"<#{object.unpack('H*')[0]}>".force_encoding(Encoding::ASCII_8BIT)