lib/hexapdf/parser.rb in hexapdf-0.17.2 vs lib/hexapdf/parser.rb in hexapdf-0.17.3

- old
+ new

@@ -402,10 +402,11 @@ # If the file contains multiple cross-reference sections, all objects will be put into a single # cross-reference table, later objects overwriting prior ones. def reconstruct_revision return if @in_reconstruct_revision @in_reconstruct_revision = true + @header_offset = 0 raise unless @document.config['parser.try_xref_reconstruction'] msg = "#{$!} - trying cross-reference table reconstruction" @document.config['parser.on_correctable_error'].call(@document, msg, @tokenizer.pos) @@ -426,11 +427,13 @@ if @tokenizer.pos > next_new_line_pos @tokenizer.pos = next_new_line_pos elsif gen.kind_of?(Integer) && tok.kind_of?(Tokenizer::Token) && tok == 'obj' xref.add_in_use_entry(token, gen, pos) if linearized.nil? + pos = @tokenizer.pos obj = @tokenizer.next_object rescue nil linearized = obj.kind_of?(Hash) && obj.key?(:Linearized) + @tokenizer.pos = pos end @tokenizer.scan_until(/(?:\n|\r\n?)endobj\b/) end elsif token.kind_of?(Tokenizer::Token) && token == 'trailer' obj = @tokenizer.next_object rescue nil