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
30 changes: 30 additions & 0 deletions src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@

public class GithubIssuesTests
{
[Fact]
public void Issue1156()
{
var path = IntegrationHelpers.GetDocumentPath("felltypes-test.pdf");

using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true }))
{
var page = document.GetPage(1);

var letters = page.Letters;

var words = NearestNeighbourWordExtractor.Instance.GetWords(letters).ToArray();

var wordThe = words[0];
Assert.Equal("THE", wordThe.Text);
Assert.Equal(wordThe.BoundingBox.BottomLeft, new PdfPoint(x: 242.9877, y: 684.7435));
Assert.Equal(wordThe.BoundingBox.BottomRight, new PdfPoint(x: 323.93999999999994, y: 684.7435));

var wordBook = words[2];
Assert.Equal("BOOK:", wordBook.Text);
Assert.Equal(wordBook.BoundingBox.BottomLeft, new PdfPoint(x: 280.4371, y: 652.0399));
Assert.Equal(wordBook.BoundingBox.BottomRight, new PdfPoint(x: 405.65439999999995, y: 652.0399));

var wordPremeffa = words[35];
Assert.Equal("preme\ue009a.", wordPremeffa.Text); // The 'ff' glyph is not properly parsed
Assert.Equal(wordPremeffa.BoundingBox.BottomLeft, new PdfPoint(x: 331.16020000000003, y: 515.2256999999998));
Assert.Equal(wordPremeffa.BoundingBox.BottomRight, new PdfPoint(x: 374.2954000000001, y: 515.2256999999998));
}
}

[Fact]
public void Issue1148()
{
Expand Down
5 changes: 2 additions & 3 deletions src/UglyToad.PdfPig/PdfFonts/Composite/Type0Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,11 @@ public CharacterBoundingBox GetBoundingBox(int characterCode)
// Get the bounding box in glyph space
var boundingBox = CidFont.GetBoundingBox(characterIdentifier);

var fontMatrix = CidFont.GetFontMatrix(characterIdentifier);
boundingBox = fontMatrix.Transform(boundingBox);
boundingBox = CidFont.GetFontMatrix(characterIdentifier).Transform(boundingBox);

var width = CidFont.GetWidthFromFont(characterIdentifier);

var advanceWidth = fontMatrix.TransformX(width);
var advanceWidth = GetFontMatrix().TransformX(width);

var result = new CharacterBoundingBox(boundingBox, advanceWidth);

Expand Down
Loading