mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-06-28 09:30:31 +08:00
Fix bug where FormXObject bbox needs to be normalised
This commit is contained in:
parent
ede77c20f5
commit
4fbcc112d3
@ -1,5 +1,7 @@
|
|||||||
namespace UglyToad.PdfPig.Tests.Integration
|
namespace UglyToad.PdfPig.Tests.Integration
|
||||||
{
|
{
|
||||||
|
using DocumentLayoutAnalysis.PageSegmenter;
|
||||||
|
using DocumentLayoutAnalysis.WordExtractor;
|
||||||
using UglyToad.PdfPig.Core;
|
using UglyToad.PdfPig.Core;
|
||||||
|
|
||||||
public class XObjectFormTests
|
public class XObjectFormTests
|
||||||
@ -32,5 +34,24 @@
|
|||||||
var page = document.GetPage(1);
|
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")));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -576,7 +576,7 @@
|
|||||||
{
|
{
|
||||||
var points = bboxToken.Data.OfType<NumericToken>().Select(x => x.Double).ToArray();
|
var points = bboxToken.Data.OfType<NumericToken>().Select(x => x.Double).ToArray();
|
||||||
PdfRectangle bbox = new PdfRectangle(points[0], points[1], points[2], points[3]);
|
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
|
ClipToRectangle(transformedBox, FillingRule.EvenOdd); // TODO - Check that Even Odd is valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user