lib/combine_pdf/renderer.rb in combine_pdf-0.2.12 vs lib/combine_pdf/renderer.rb in combine_pdf-0.2.13

- old
+ new

@@ -110,19 +110,22 @@ out << object_to_pdf(object[:indirect_without_dictionary]) out << "\nendobj\n" return out.join().force_encoding(Encoding::ASCII_8BIT) end end + # remove extra page references. + object[:Contents].delete({ is_reference_only: true , referenced_object: {indirect_reference_id: 0, raw_stream_content: ''} }) if object[:Type] == :Page # correct stream length, if the object is a stream. object[:Length] = object[:raw_stream_content].bytesize if object[:raw_stream_content] # if the object is not a simple object, it is a dictionary # A dictionary shall be written as a sequence of key-value pairs enclosed in double angle brackets (<<...>>) # (using LESS-THAN SIGNs (3Ch) and GREATER-THAN SIGNs (3Eh)). out << "<<\n".force_encoding(Encoding::ASCII_8BIT) object.each do |key, value| out << "#{object_to_pdf key} #{object_to_pdf value}\n".force_encoding(Encoding::ASCII_8BIT) unless PDF::PRIVATE_HASH_KEYS.include? key end + object.delete :Length out << ">>".force_encoding(Encoding::ASCII_8BIT) out << "\nstream\n#{object[:raw_stream_content]}\nendstream".force_encoding(Encoding::ASCII_8BIT) if object[:raw_stream_content] out << "\nendobj\n" if object[:indirect_reference_id] out.join().force_encoding(Encoding::ASCII_8BIT) end