diff --git a/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs b/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs index 941be3a8..9fc1f485 100644 --- a/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs +++ b/src/UglyToad.PdfPig/Tokenization/Scanner/PdfTokenScanner.cs @@ -8,9 +8,7 @@ using System.Text.RegularExpressions; using Core; using Encryption; - using Exceptions; using Filters; - using Parser.Parts; using Tokens; internal class PdfTokenScanner : IPdfTokenScanner @@ -144,6 +142,21 @@ coreTokenScanner.Seek(previousTokenPositions[0]); break; } + + if (readTokens.Count == 3 && readTokens[1] is NumericToken extraObjNum && readTokens[2] is NumericToken extraGenNum) + { + // An obj was encountered after reading the actual token and the object and generation number of the following token. + var actualReference = new IndirectReference(objectNumber.Int, generation.Int); + var actualToken = encryptionHandler.Decrypt(actualReference, readTokens[0]); + + CurrentToken = new ObjectToken(startPosition, actualReference, actualToken); + + readTokens.Clear(); + coreTokenScanner.Seek(previousTokenPositions[0]); + + return true; + } + // This should never happen. Debug.Assert(false, "Encountered a start object 'obj' operator before the end of the previous object."); return false; diff --git a/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj b/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj index 406543ec..d39cb33f 100644 --- a/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj +++ b/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj @@ -9,7 +9,7 @@ Reads text content from PDF documents and supports document creation. Apache 2.0 licensed. Apache-2.0 https://github.com/UglyToad/PdfPig - PDF;Reader;Document;Adobe;PDFBox;PdfPig;pdf-extract + PDF;Reader;Document;Adobe;PDFBox;PdfPig;pdf-extract;pdf-to-text;pdf;file;text;C#;dotnet;.NET https://github.com/UglyToad/PdfPig true 0.1.2