diff --git a/src/UglyToad.PdfPig.Tests/Integration/Documents/6.Secrets.to.Startup.Success.PDFDrive.pdf b/src/UglyToad.PdfPig.Tests/Integration/Documents/6.Secrets.to.Startup.Success.PDFDrive.pdf new file mode 100644 index 000000000..4b4cd34c9 Binary files /dev/null and b/src/UglyToad.PdfPig.Tests/Integration/Documents/6.Secrets.to.Startup.Success.PDFDrive.pdf differ diff --git a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs index 8d2a48bea..6c343f8e9 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs @@ -11,6 +11,20 @@ public class GithubIssuesTests { + [Fact] + public void Issues1238() + { + var path = IntegrationHelpers.GetDocumentPath("6.Secrets.to.Startup.Success.PDFDrive.pdf"); + + using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true })) + { + var page = document.GetPage(159); + Assert.NotNull(page); + Assert.StartsWith("uct. At the longer-cycle, broader end of the spectrum are identity-level", page.Text); + Assert.Equal(0, page.Rotation.Value); + } + } + [Fact] public void Issue1217() { diff --git a/src/UglyToad.PdfPig/Util/DictionaryTokenExtensions.cs b/src/UglyToad.PdfPig/Util/DictionaryTokenExtensions.cs index 4de1c8190..f0e278e58 100644 --- a/src/UglyToad.PdfPig/Util/DictionaryTokenExtensions.cs +++ b/src/UglyToad.PdfPig/Util/DictionaryTokenExtensions.cs @@ -250,8 +250,9 @@ public static PdfRectangle ToRectangle(this ArrayToken array, IPdfTokenScanner t throw new ArgumentNullException(nameof(array)); } - if (array.Data.Count != 4) + if (array.Data.Count < 4) { + // Should be exactly 4, but can be more (see issues 1238). We ignore the rest. throw new PdfDocumentFormatException($"Cannot convert array to rectangle, expected 4 values instead got: {array.Data.Count}."); }