lib/combine_pdf/parser.rb in combine_pdf-1.0.12 vs lib/combine_pdf/parser.rb in combine_pdf-1.0.13

- old
+ new

@@ -110,16 +110,17 @@ @parsed.length.times do |i| o = @parsed[i] next unless o.is_a?(Hash) && o[:Type] == :ObjStm ## un-encode (using the correct filter) the object streams PDFFilter.inflate_object o + # puts "Object Stream Found:", o[:raw_stream_content] ## extract objects from stream @scanner = StringScanner.new o[:raw_stream_content] stream_data = _parse_ id_array = [] collection = [nil] - while stream_data[0].is_a? (Numeric) + while (stream_data[0].is_a?(Numeric) && stream_data[1].is_a?(Numeric)) id_array << stream_data.shift stream_data.shift end while id_array[0] && stream_data[0] stream_data[0] = { indirect_without_dictionary: stream_data[0] } unless stream_data[0].is_a?(Hash) @@ -476,10 +477,10 @@ ########################################## ## Unknown, warn and advance ########################################## else # always advance - warn "Advancing for unknown reason... #{@scanner.string[@scanner.pos - 4, 8]} ... #{@scanner.peek(4)}" unless @scanner.peek(1) =~ /[\s\n]/ + # warn "Advancing for unknown reason... #{@scanner.string[@scanner.pos - 4, 8]} ... #{@scanner.peek(4)}" unless @scanner.peek(1) =~ /[\s\n]/ warn 'Warning: parser advancing for unknown reason. Potential data-loss.' @scanner.pos = @scanner.pos + 1 end end out