From 872e338ecb960ea765cad65aeed72b319975b18b Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sun, 19 May 2019 12:58:49 +0100 Subject: [PATCH] skip invalid commands in type 1 command definitions --- .../Fonts/Type1/CharStrings/Type1CharStringParser.cs | 3 ++- .../Fonts/Type1/Parser/Type1CharstringDecryptedBytes.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/UglyToad.PdfPig/Fonts/Type1/CharStrings/Type1CharStringParser.cs b/src/UglyToad.PdfPig/Fonts/Type1/CharStrings/Type1CharStringParser.cs index 846c454b..d41294a3 100644 --- a/src/UglyToad.PdfPig/Fonts/Type1/CharStrings/Type1CharStringParser.cs +++ b/src/UglyToad.PdfPig/Fonts/Type1/CharStrings/Type1CharStringParser.cs @@ -83,7 +83,8 @@ if (command == null) { - throw new InvalidOperationException($"Could not find command with code {b}."); + // Treat as invalid but skip + continue; } interpreted.Add(new Union.Case2(command)); diff --git a/src/UglyToad.PdfPig/Fonts/Type1/Parser/Type1CharstringDecryptedBytes.cs b/src/UglyToad.PdfPig/Fonts/Type1/Parser/Type1CharstringDecryptedBytes.cs index 99d88fb4..3e9a721e 100644 --- a/src/UglyToad.PdfPig/Fonts/Type1/Parser/Type1CharstringDecryptedBytes.cs +++ b/src/UglyToad.PdfPig/Fonts/Type1/Parser/Type1CharstringDecryptedBytes.cs @@ -34,5 +34,10 @@ Subroutine, Charstring } + + public override string ToString() + { + return $"{Name} {Source} {Index} {Bytes.Count} bytes"; + } } }