Skip to content

Commit

Permalink
Handle null state in SetNamedGraphicsState (see UglyToad/PdfPig#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobLd committed Aug 22, 2024
1 parent 2eb09bf commit 3056bc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Caly.Pdf/TextLayer/TextLayerNoDupStreamProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public override void SetNamedGraphicsState(NameToken stateName)
{
var state = ResourceStore.GetExtendedGraphicsStateDictionary(stateName);

if (state is null)
{
return;
}

// Only do text related ngs

if (state.TryGet(NameToken.Font, PdfScanner, out ArrayToken? fontArray) && fontArray.Length == 2
Expand Down
5 changes: 5 additions & 0 deletions Caly.Pdf/TextLayer/TextLayerStreamProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ public override void SetNamedGraphicsState(NameToken stateName)
{
var state = ResourceStore.GetExtendedGraphicsStateDictionary(stateName);

if (state is null)
{
return;
}

// Only do text related ngs

if (state.TryGet(NameToken.Font, PdfScanner, out ArrayToken? fontArray) && fontArray.Length == 2
Expand Down

0 comments on commit 3056bc9

Please sign in to comment.