diff --git a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs index 88a05ae5f..71c3cff7d 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs @@ -7,6 +7,29 @@ public class GithubIssuesTests { + [Fact] + public void Issue1016() + { + // Doc has letters with Shading pattern color + + var path = IntegrationHelpers.GetSpecificTestDocumentPath("colorcomparecrash.pdf"); + + using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true, SkipMissingFonts = true })) + { + var page = document.GetPage(1); + + var letters = page.Letters; + + var firstLetter = letters[0]; + Assert.NotNull(firstLetter.Color); + + var secondLetter = letters[1]; + Assert.NotNull(secondLetter.Color); + + Assert.True(firstLetter.Color.Equals(secondLetter.Color)); + } + } + [Fact] public void Issue953() { diff --git a/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/colorcomparecrash.pdf b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/colorcomparecrash.pdf new file mode 100644 index 000000000..7e9642a37 Binary files /dev/null and b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/colorcomparecrash.pdf differ diff --git a/src/UglyToad.PdfPig/Graphics/Colors/PatternColor.cs b/src/UglyToad.PdfPig/Graphics/Colors/PatternColor.cs index 78b7d908e..47341af4b 100644 --- a/src/UglyToad.PdfPig/Graphics/Colors/PatternColor.cs +++ b/src/UglyToad.PdfPig/Graphics/Colors/PatternColor.cs @@ -158,7 +158,7 @@ public bool Equals(TilingPatternColor? other) return PatternType.Equals(other.PatternType) && Matrix.Equals(other.Matrix) && - ExtGState.Equals(other.ExtGState) && + ((ExtGState is null && other.ExtGState is null) || ExtGState?.Equals(other.ExtGState) == true) && PaintType.Equals(other.PaintType) && TilingType.Equals(other.TilingType) && BBox.Equals(other.BBox) && @@ -225,7 +225,7 @@ public bool Equals(ShadingPatternColor? other) return PatternType.Equals(other.PatternType) && Matrix.Equals(other.Matrix) && - ExtGState.Equals(other.ExtGState) && + ((ExtGState is null && other.ExtGState is null) || ExtGState?.Equals(other.ExtGState) == true) && Shading.Equals(other.Shading); }