From 3cd81297c19a2164ef9451154fa54718524118c2 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sat, 2 Jul 2022 18:09:11 -0400 Subject: [PATCH] handle infinity symbol encountered in edge-case files --- src/UglyToad.PdfPig/Parser/PageContentParser.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/UglyToad.PdfPig/Parser/PageContentParser.cs b/src/UglyToad.PdfPig/Parser/PageContentParser.cs index 87f0cb52..e6a8e5f5 100644 --- a/src/UglyToad.PdfPig/Parser/PageContentParser.cs +++ b/src/UglyToad.PdfPig/Parser/PageContentParser.cs @@ -94,7 +94,7 @@ throw new InvalidOperationException($"Failed to read expected buffer length {gap} on page {pageNumber} " + $"when reading inline image at offset in content: {lastEndImageOffset.Value}."); } - + // Replace the last end image operator with one containing the full set of data. graphicsStateOperations.Remove(lastEndImage); graphicsStateOperations.Add(new EndInlineImage(lastEndImage.ImageData.Concat(missingData).ToArray())); @@ -142,6 +142,13 @@ graphicsStateOperations.Add(newEndInlineImage); lastEndImageOffset = scanner.CurrentPosition - 3; } + else if (op.Data == "inf") + { + // Value representing infinity in broken file from #467. + // Treat as zero. + precedingTokens.Add(NumericToken.Zero); + continue; + } else { log.Warn($"Operator which was not understood encountered. Values was {op.Data}. Ignoring.");