From 8998df18e776b4bf17a4c731e0b9c3aad926ca6d Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 12 Apr 2016 14:56:05 +0200 Subject: Changed automatic positioning to handle annotation partly above the footerline, introduced legacy40.pos option to disable the change --- .../java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java') diff --git a/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java b/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java index 7bb300ad..d02f23b0 100644 --- a/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java +++ b/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java @@ -128,6 +128,8 @@ public class PDFPage extends PDFTextStripper { */ private GeneralPath currentPath = new GeneralPath(); + private boolean legacy40; + /** * The lowest position of a drawn path (originating from top). */ @@ -142,10 +144,12 @@ public class PDFPage extends PDFTextStripper { * * @throws java.io.IOException */ - public PDFPage(float effectivePageHeight, boolean legacy32) + public PDFPage(float effectivePageHeight, boolean legacy32, boolean legacy40) throws IOException { super(); + this.legacy40 = legacy40; + this.effectivePageHeight = effectivePageHeight; OperatorProcessor newInvoke = new MyInvoke(this); @@ -603,6 +607,7 @@ public class PDFPage extends PDFTextStripper { public void processAnnotation(PDAnnotation anno) { float current_y = anno.getRectangle().getLowerLeftY(); + float upper_y = 0; PDPage page = anno.getPage(); if (page == null) { @@ -619,19 +624,31 @@ public class PDFPage extends PDFTextStripper { if (pageRotation == 0) { float page_height = page.findMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getLowerLeftY(); + upper_y = page_height - anno.getRectangle().getUpperRightY(); } if (pageRotation == 90) { current_y = anno.getRectangle().getUpperRightX(); + upper_y = anno.getRectangle().getLowerLeftX(); } if (pageRotation == 180) { current_y = anno.getRectangle().getUpperRightY(); + upper_y = anno.getRectangle().getLowerLeftY(); } if (pageRotation == 270) { float page_width = page.findMediaBox().getWidth(); current_y = page_width - anno.getRectangle().getLowerLeftX(); + upper_y = page_width - anno.getRectangle().getUpperRightX(); } + + if (current_y > this.effectivePageHeight) { + if(!this.legacy40 && upper_y < this.effectivePageHeight) { + // Bottom of annotation is below footer line, + // but top of annotation is above footer line! + // so no place left on this page! + this.max_character_ypos = this.effectivePageHeight; + } return; } -- cgit v1.2.3