Skip to content

Commit 74d61bd

Browse files
committed
Fix PatternColor Equals() method and fix #1016
1 parent ba8e1e1 commit 74d61bd

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@
77

88
public class GithubIssuesTests
99
{
10+
[Fact]
11+
public void Issue1016()
12+
{
13+
// Doc has letters with Shading pattern color
14+
15+
var path = IntegrationHelpers.GetSpecificTestDocumentPath("colorcomparecrash.pdf");
16+
17+
using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true, SkipMissingFonts = true }))
18+
{
19+
var page = document.GetPage(1);
20+
21+
var letters = page.Letters;
22+
23+
var firstLetter = letters[0];
24+
Assert.NotNull(firstLetter.Color);
25+
26+
var secondLetter = letters[1];
27+
Assert.NotNull(secondLetter.Color);
28+
29+
Assert.True(firstLetter.Color.Equals(secondLetter.Color));
30+
}
31+
}
32+
1033
[Fact]
1134
public void Issue953()
1235
{
Binary file not shown.

src/UglyToad.PdfPig/Graphics/Colors/PatternColor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public bool Equals(TilingPatternColor? other)
158158

159159
return PatternType.Equals(other.PatternType) &&
160160
Matrix.Equals(other.Matrix) &&
161-
ExtGState.Equals(other.ExtGState) &&
161+
((ExtGState is null && other.ExtGState is null) || ExtGState?.Equals(other.ExtGState) == true) &&
162162
PaintType.Equals(other.PaintType) &&
163163
TilingType.Equals(other.TilingType) &&
164164
BBox.Equals(other.BBox) &&
@@ -225,7 +225,7 @@ public bool Equals(ShadingPatternColor? other)
225225

226226
return PatternType.Equals(other.PatternType) &&
227227
Matrix.Equals(other.Matrix) &&
228-
ExtGState.Equals(other.ExtGState) &&
228+
((ExtGState is null && other.ExtGState is null) || ExtGState?.Equals(other.ExtGState) == true) &&
229229
Shading.Equals(other.Shading);
230230
}
231231

0 commit comments

Comments
 (0)