Skip to content

Commit

Permalink
fixes #206
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzido committed Mar 1, 2018
1 parent 4e15a50 commit 01074f3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ private void strokeOrFillPath(boolean isFill) {
case PathIterator.SEG_LINETO:
end_pos = new Point2D.Float(c[0], c[1]);

if (start_pos == null || end_pos == null) {
break;
}

line = pc.compare(start_pos, end_pos) == -1 ? new Line2D.Float(start_pos, end_pos)
: new Line2D.Float(end_pos, start_pos);

Expand All @@ -216,6 +220,9 @@ private void strokeOrFillPath(boolean isFill) {
// segment
// back to the point corresponding to the most recent
// SEG_MOVETO."
if (start_pos == null || end_pos == null) {
break;
}
line = pc.compare(end_pos, last_move) == -1 ? new Line2D.Float(end_pos, last_move)
: new Line2D.Float(last_move, end_pos);

Expand Down
12 changes: 12 additions & 0 deletions src/test/java/technology/tabula/TestObjectExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ public void testTextElementsContainedInPage() throws IOException {
assertTrue(page.contains(te));
}
}

@Test public void testDoNotNPEInPointComparator() throws IOException {
PDDocument pdf_document = PDDocument.load(new File("src/test/resources/technology/tabula/npe_issue_206.pdf"));
ObjectExtractor oe = new ObjectExtractor(pdf_document);

try {
Page p = oe.extractPage(1);
assertNotNull(p);
} catch (NullPointerException e) {
fail("NPE in ObjectExtractor " + e.toString());
}
}

/*
@Test
Expand Down
Binary file not shown.

0 comments on commit 01074f3

Please sign in to comment.