diff --git a/src/PdfSharp/Pdf.IO/Parser.cs b/src/PdfSharp/Pdf.IO/Parser.cs index a5d12ac3..a20258dc 100644 --- a/src/PdfSharp/Pdf.IO/Parser.cs +++ b/src/PdfSharp/Pdf.IO/Parser.cs @@ -261,6 +261,7 @@ public PdfObject ReadObject(PdfObject pdfObject, PdfObjectID objectID, bool incl ParserDiagnostics.HandleUnexpectedToken(_lexer.Token); break; } + int revert_pos = _lexer.Position; symbol = ScanNextToken(); if (symbol == Symbol.BeginStream) { @@ -299,11 +300,12 @@ public PdfObject ReadObject(PdfObject pdfObject, PdfObjectID objectID, bool incl PdfDictionary.PdfStream stream = new PdfDictionary.PdfStream(bytes, dict); dict.Stream = stream; ReadSymbol(Symbol.EndStream); + revert_pos = _lexer.Position; symbol = ScanNextToken(); #endif } - if (!fromObjecStream && symbol != Symbol.EndObj) - ParserDiagnostics.ThrowParserException(PSSR.UnexpectedToken(_lexer.Token)); + if (!fromObjecStream && symbol != Symbol.EndObj) + _lexer.Position = revert_pos; return pdfObject; }