diff --git a/src/UglyToad.PdfPig.Tests/Integration/XObjectFormTests.cs b/src/UglyToad.PdfPig.Tests/Integration/XObjectFormTests.cs index 2ffb54d2..4c1216dd 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/XObjectFormTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/XObjectFormTests.cs @@ -1,5 +1,7 @@ namespace UglyToad.PdfPig.Tests.Integration { + using DocumentLayoutAnalysis.PageSegmenter; + using DocumentLayoutAnalysis.WordExtractor; using UglyToad.PdfPig.Core; public class XObjectFormTests @@ -32,5 +34,24 @@ 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"))); + } + } } } diff --git a/src/UglyToad.PdfPig/Graphics/BaseStreamProcessor.cs b/src/UglyToad.PdfPig/Graphics/BaseStreamProcessor.cs index 43758be4..035f8238 100644 --- a/src/UglyToad.PdfPig/Graphics/BaseStreamProcessor.cs +++ b/src/UglyToad.PdfPig/Graphics/BaseStreamProcessor.cs @@ -576,7 +576,7 @@ { var points = bboxToken.Data.OfType().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 }