diff --git a/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs b/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs index 01f11a96..01f9d175 100644 --- a/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs +++ b/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs @@ -291,12 +291,15 @@ return new CharacterIdentifierToGlyphIndexMap(); } - if (entry is NameToken) + if (DirectObjectFinder.TryGet(entry, pdfScanner, out NameToken _)) { return new CharacterIdentifierToGlyphIndexMap(); } - var stream = DirectObjectFinder.Get(entry, pdfScanner); + if (!DirectObjectFinder.TryGet(entry, pdfScanner, out StreamToken stream)) + { + throw new PdfDocumentFormatException($"No stream or name token found for /CIDToGIDMap in dictionary: {dictionary}."); + } var bytes = stream.Decode(filterProvider);