make ext gstates stacked
Some checks failed
Build, test and publish draft / build (push) Has been cancelled
Build and test [MacOS] / build (push) Has been cancelled
Run Common Crawl Tests / build (0000-0001) (push) Has been cancelled
Run Common Crawl Tests / build (0002-0003) (push) Has been cancelled
Run Common Crawl Tests / build (0004-0005) (push) Has been cancelled
Run Common Crawl Tests / build (0006-0007) (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
Nightly Release / Check if this commit has already been published (push) Has been cancelled
Nightly Release / tests (push) Has been cancelled
Nightly Release / build_and_publish_nightly (push) Has been cancelled

This commit is contained in:
Alexander Vinnikov
2026-02-05 19:14:17 +01:00
committed by BobLd
parent d6e86b057e
commit d69e3fa6a9

View File

@@ -24,7 +24,7 @@
private readonly StackDictionary<NameToken, IndirectReference> currentFontState = new StackDictionary<NameToken, IndirectReference>();
private readonly StackDictionary<NameToken, IndirectReference> currentXObjectState = new StackDictionary<NameToken, IndirectReference>();
private readonly Dictionary<NameToken, DictionaryToken> extendedGraphicsStates = new Dictionary<NameToken, DictionaryToken>();
private readonly StackDictionary<NameToken, DictionaryToken> extendedGraphicsStates = new StackDictionary<NameToken, DictionaryToken>();
private readonly StackDictionary<NameToken, ResourceColorSpace> namedColorSpaces = new StackDictionary<NameToken, ResourceColorSpace>();
private readonly Dictionary<NameToken, ColorSpaceDetails> loadedNamedColorSpaceDetails = new Dictionary<NameToken, ColorSpaceDetails>();
@@ -55,7 +55,8 @@
namedColorSpaces.Push();
currentFontState.Push();
currentXObjectState.Push();
currentXObjectState.Push();
extendedGraphicsStates.Push();
if (resourceDictionary.TryGet(NameToken.Font, out var fontBase))
{
@@ -190,6 +191,7 @@
currentFontState.Pop();
currentXObjectState.Pop();
namedColorSpaces.Pop();
extendedGraphicsStates.Pop();
}
private void LoadFontDictionary(DictionaryToken fontDictionary)
@@ -348,8 +350,13 @@
public DictionaryToken? GetExtendedGraphicsStateDictionary(NameToken name)
{
if (parsingOptions.UseLenientParsing && !extendedGraphicsStates.ContainsKey(name))
{
if (parsingOptions.UseLenientParsing)
{
if (extendedGraphicsStates.TryGetValue(name, out var dictToken))
{
return dictToken;
}
parsingOptions.Logger.Error($"The graphic state dictionary does not contain the key '{name}'.");
return null;
}