From e9410c03edfcfee9b6aa6dc5a27d6532292d72d8 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 7 May 2014 09:24:50 +0200 Subject: Fixed Annotation without page warning --- .../java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pdf-as-lib/src/main/java/at') diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java index f2cd4085..4ce8daa9 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java @@ -537,11 +537,21 @@ public class PDFPage extends PDFTextStripper { public void processAnnotation(PDAnnotation anno) { float current_y = anno.getRectangle().getLowerLeftY(); + PDPage page = anno.getPage(); - int pageRotation = anno.getPage().findRotation(); + if(page == null) { + page = getCurrentPage(); + } + + if(page == null) { + logger.warn("Annotation without page! The position might not be correct!"); + return; + } + + int pageRotation = page.findRotation(); // logger_.debug("PageRotation = " + pageRotation); if (pageRotation == 0) { - float page_height = anno.getPage().findMediaBox().getHeight(); + float page_height = page.findMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getLowerLeftY(); } if (pageRotation == 90) { @@ -551,7 +561,7 @@ public class PDFPage extends PDFTextStripper { current_y = anno.getRectangle().getUpperRightY(); } if (pageRotation == 270) { - float page_height = anno.getPage().findMediaBox().getHeight(); + float page_height = page.findMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getUpperRightX(); } -- cgit v1.2.3