Skip to content

Commit d1d79b0

Browse files
committed
Check ColorSpace token as dictionary and fix issue #1061
1 parent 89abf6d commit d1d79b0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/UglyToad.PdfPig/Content/ResourceStore.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ public void LoadResourceDictionary(DictionaryToken resourceDictionary)
119119

120120
namedColorSpaces[name] = new ResourceColorSpace(arrayNamedColorSpace, colorSpaceArray);
121121
}
122+
else if (parsingOptions.UseLenientParsing &&
123+
DirectObjectFinder.TryGet(nameColorSpacePair.Value, scanner, out DictionaryToken? dict) &&
124+
dict.TryGet(NameToken.ColorSpace, scanner, out NameToken? csName))
125+
{
126+
// See issue #1061
127+
namedColorSpaces[name] = new ResourceColorSpace(csName);
128+
}
122129
else
123130
{
124131
throw new PdfDocumentFormatException($"Invalid ColorSpace token encountered in page resource dictionary: {nameColorSpacePair.Value}.");

0 commit comments

Comments
 (0)