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
21 changes: 21 additions & 0 deletions src/UglyToad.PdfPig.Tests/Integration/XObjectFormTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using DocumentLayoutAnalysis.PageSegmenter;
using DocumentLayoutAnalysis.WordExtractor;
using UglyToad.PdfPig.Core;

public class XObjectFormTests
Expand Down Expand Up @@ -32,5 +34,24 @@ public void CanReadDocumentMOZILLA_3136_0()
var page = document.GetPage(1);
}
}

[Fact]
public void XObjectFormXClipping()
{
using (var document = PdfDocument.Open(IntegrationHelpers.GetDocumentPath("ICML03-081"), new ParsingOptions()
{
ClipPaths = true
}))
{
var page = document.GetPage(4);
Assert.True(page.Paths.Count > 3);

var words = page.GetWords(NearestNeighbourWordExtractor.Instance);
var blocks = DocstrumBoundingBoxes.Instance.GetBlocks(words).SelectMany(b => b.TextLines).ToArray();

Assert.Equal(2, blocks.Count(l => l.Text.Equals("Training Examples per Class")));
Assert.Equal(2, blocks.Count(l => l.Text.Equals("Classification Weight")));
}
}
}
}
2 changes: 1 addition & 1 deletion src/UglyToad.PdfPig/Graphics/BaseStreamProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ protected virtual void ProcessFormXObject(StreamToken formStream, NameToken xObj
{
var points = bboxToken.Data.OfType<NumericToken>().Select(x => x.Double).ToArray();
PdfRectangle bbox = new PdfRectangle(points[0], points[1], points[2], points[3]);
PdfRectangle transformedBox = startState.CurrentTransformationMatrix.Transform(bbox);
PdfRectangle transformedBox = startState.CurrentTransformationMatrix.Transform(bbox).Normalise();
ClipToRectangle(transformedBox, FillingRule.EvenOdd); // TODO - Check that Even Odd is valid
}

Expand Down
Loading