lib/combine_pdf/renderer.rb in combine_pdf-1.0.10 vs lib/combine_pdf/renderer.rb in combine_pdf-1.0.11
- old
+ new
@@ -18,12 +18,14 @@
return format_string_to_pdf object
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?(Numeric) || object.is_a?(TrueClass) || object.is_a?(FalseClass)
+ elsif object.is_a?(Integer) || object.is_a?(TrueClass) || object.is_a?(FalseClass)
return object.to_s
+ elsif object.is_a?(Numeric) # Float or other non-integer
+ return sprintf('%f', object)
elsif object.is_a?(Hash)
return format_hash_to_pdf object
else
return ''
end
@@ -45,10 +47,10 @@
def format_string_to_pdf(object)
obj_bytes = object.bytes.to_a
# object.force_encoding(Encoding::ASCII_8BIT)
if object.length == 0 || obj_bytes.min <= 31 || obj_bytes.max >= 127 # || (obj_bytes[0] != 68 object.match(/[^D\:\d\+\-Z\']/))
- # A hexadecimal string shall be written as a sequence of hexadecimal digits (0–9 and either A–F or a–f)
+ # 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)
else
# a good fit for a Literal String or the string is a date (MUST be literal)
('(' + ([].tap { |out| obj_bytes.each { |byte| out.concat(STRING_REPLACEMENT_ARRAY[byte]) } } ).pack('C*') + ')').force_encoding(Encoding::ASCII_8BIT)