diff --git a/src/UglyToad.PdfPig.Tests/Tokenization/Scanner/CoreTokenScannerTests.cs b/src/UglyToad.PdfPig.Tests/Tokenization/Scanner/CoreTokenScannerTests.cs index da16e242b..e4eb551a6 100644 --- a/src/UglyToad.PdfPig.Tests/Tokenization/Scanner/CoreTokenScannerTests.cs +++ b/src/UglyToad.PdfPig.Tests/Tokenization/Scanner/CoreTokenScannerTests.cs @@ -261,6 +261,47 @@ public void SkipsCommentsInStreams() Assert.Equal(3, tokens.OfType().Count()); } + [Fact] + public void Document006324Test() + { + const string content = + """ + q + 1 0 0 1 248.6304 572.546 cm + 0 0 m + 0.021 -0.007 l + 3 -0.003 -0.01 0 0 0 c + f + Q + q + 1 0 0 1 2489394 57249855 cm + 0 0 m + -0.046 -0.001 -0.609 0.029 -0.286 -0.014 c + -02.61 -0.067 -0.286 -0. .61 -0 0 c + f + Q + q + 1 0 0 1 24862464 572. .836 cm + 0 0 m + 0.936 -0.029 l + 0.038 -0.021 0.55 -0.014 0 0 c + f + Q + """; + + var tokens = new List(); + + var scanner = new CoreTokenScanner( + StringBytesTestConverter.Convert(content, false).Bytes, + true, + isStream: true); + + while (scanner.MoveNext()) + { + tokens.Add(scanner.CurrentToken); + } + } + private static void AssertCorrectToken(IToken token, TData expected) where T : IDataToken { var cast = Assert.IsType(token); diff --git a/src/UglyToad.PdfPig/Parser/CatalogFactory.cs b/src/UglyToad.PdfPig/Parser/CatalogFactory.cs index 1fea5462a..c6d2d73d3 100644 --- a/src/UglyToad.PdfPig/Parser/CatalogFactory.cs +++ b/src/UglyToad.PdfPig/Parser/CatalogFactory.cs @@ -19,7 +19,8 @@ public static Catalog Create(IndirectReference rootReference, DictionaryToken di throw new ArgumentNullException(nameof(dictionary)); } - if (dictionary.TryGet(NameToken.Type, out var type) && !ReferenceEquals(type, NameToken.Catalog)) + if (dictionary.TryGet(NameToken.Type, out var type) && !ReferenceEquals(type, NameToken.Catalog) + && !isLenientParsing) { throw new PdfDocumentFormatException($"The type of the catalog dictionary was not Catalog: {dictionary}."); }