diff --git a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs index e3c41d41..c89a83f6 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs @@ -7,6 +7,24 @@ public class GithubIssuesTests { + [Fact] + public void Issue1054() + { + var path = IntegrationHelpers.GetSpecificTestDocumentPath("MOZILLA-11518-0.pdf"); + + using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true })) + { + for (int p = 1; p <= document.NumberOfPages; p++) + { + var page = document.GetPage(p); + foreach (var image in page.GetImages()) + { + Assert.NotNull(image); + } + } + } + } + [Fact] public void Issue1050() { diff --git a/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/MOZILLA-11518-0.pdf b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/MOZILLA-11518-0.pdf new file mode 100644 index 00000000..a1eebc48 Binary files /dev/null and b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/MOZILLA-11518-0.pdf differ diff --git a/src/UglyToad.PdfPig/XObjects/XObjectFactory.cs b/src/UglyToad.PdfPig/XObjects/XObjectFactory.cs index 9892281c..6a319241 100644 --- a/src/UglyToad.PdfPig/XObjects/XObjectFactory.cs +++ b/src/UglyToad.PdfPig/XObjects/XObjectFactory.cs @@ -73,10 +73,16 @@ } else if (dictionary.TryGet(NameToken.Mask, out StreamToken maskStream)) { - if (maskStream.StreamDictionary.ContainsKey(NameToken.ColorSpace)) - { - throw new Exception("The SMask dictionary contains a 'ColorSpace'."); - } + /* As per Pdf Specifications: + * "The image dictionary shall not contain a ColorSpace entry because sample values represent masking properties (1 bit per sample) rather than colours." + * + * TODO - We assume here lenient parsing, but we should actually get the value from parsing options. See Issue #1054 + * + * if (maskStream.StreamDictionary.ContainsKey(NameToken.ColorSpace)) + * { + * throw new Exception("The SMask dictionary contains a 'ColorSpace'."); + * } + */ // Stencil masking XObjectContentRecord maskImageRecord = new XObjectContentRecord(XObjectType.Image,