diff --git a/src/UglyToad.PdfPig.Tests/Integration/Documents/Type3Test.pdf b/src/UglyToad.PdfPig.Tests/Integration/Documents/Type3Test.pdf new file mode 100644 index 000000000..ad26152bc Binary files /dev/null and b/src/UglyToad.PdfPig.Tests/Integration/Documents/Type3Test.pdf differ diff --git a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs index ad86ea028..dad8be9a8 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs @@ -11,6 +11,18 @@ public class GithubIssuesTests { + [Fact] + public void Issues1349() + { + var path = IntegrationHelpers.GetDocumentPath("Type3Test.pdf"); + using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true })) + { + var page = document.GetPage(1); + Assert.NotNull(page); + Assert.NotNull(page.Text); + } + } + [Fact] public void Issues1330() { diff --git a/src/UglyToad.PdfPig/PdfFonts/Simple/Type3Font.cs b/src/UglyToad.PdfPig/PdfFonts/Simple/Type3Font.cs index 34afa1749..b84d98c4b 100644 --- a/src/UglyToad.PdfPig/PdfFonts/Simple/Type3Font.cs +++ b/src/UglyToad.PdfPig/PdfFonts/Simple/Type3Font.cs @@ -136,7 +136,12 @@ private PdfRectangle GetBoundingBoxInGlyphSpace(int characterCode) { if (characterCode < firstChar || characterCode > lastChar) { - throw new InvalidFontFormatException($"The character code was not contained in the widths array: {characterCode}."); + // The code is outside the Widths array range. This is legal: a content + // stream may show codes (e.g. space, 32) that the font does not define a + // glyph for. Such codes have no glyph to paint (no CharProc), so report an + // empty bounding box rather than throwing. The advance width still comes + // from GetWidth, which falls back to the FontBBox width for these codes. + return new PdfRectangle(0, 0, boundingBox.Right, 0); } // The CharProc's d1 operator would declare a precise per-glyph