Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
12 changes: 12 additions & 0 deletions src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
7 changes: 6 additions & 1 deletion src/UglyToad.PdfPig/PdfFonts/Simple/Type3Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading