lib/combine_pdf/renderer.rb in combine_pdf-0.2.14 vs lib/combine_pdf/renderer.rb in combine_pdf-0.2.15

- old
+ new

@@ -51,11 +51,11 @@ # object.force_encoding(Encoding::ASCII_8BIT) if !object.match(/[^D\:\d\+\-\Z\']/) #if format is set to Literal ("(" + ([].tap {|out| object.bytes.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)). + # 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) end end def format_name_to_pdf(object) # a name object is an atomic symbol uniquely defined by a sequence of ANY characters (8-bit values) except null (character code 0). @@ -81,11 +81,11 @@ end def format_array_to_pdf(object) # An array shall be written as a sequence of objects enclosed in SQUARE BRACKETS (using LEFT SQUARE BRACKET (5Bh) and RIGHT SQUARE BRACKET (5Dh)). # EXAMPLE [549 3.14 false (Ralph) /SomeName] ("[" + (object.collect {|item| object_to_pdf(item)}).join(' ') + "]").force_encoding(Encoding::ASCII_8BIT) - + end def format_hash_to_pdf(object) # if the object is only a reference: # special conditions apply, and there is only the setting of the reference (if needed) and output @@ -131,9 +131,15 @@ out.join().force_encoding(Encoding::ASCII_8BIT) end def actual_object obj obj.is_a?(Hash) ? (obj[:referenced_object] || obj) : obj + end + + def actual_value obj + return obj unless obj.is_a?(Hash) + obj = obj[:referenced_object] || obj + obj[:indirect_without_dictionary] || obj end # Ruby normally assigns pointes. # noramlly: # a = [1,2,3] # => [1,2,3]