From 0c1bea550142c9e1571ced54976cb0167b2fc55b Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Mon, 15 Feb 2016 13:56:39 +0100 Subject: Automatic positioning with footer line fix --- .../at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'pdf-as-pdfbox/src/main/java/at/knowcenter/wag') 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 dfe31ef8..7bb300ad 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 @@ -329,7 +329,7 @@ public class PDFPage extends PDFTextStripper { int pageRotation = this.getCurrentPage().findRotation(); // logger_.debug("PageRotation = " + pageRotation); - if (pageRotation == 0) { + /*if (pageRotation == 0) { current_y = text.getY(); } if (pageRotation == 90) { @@ -350,8 +350,34 @@ public class PDFPage extends PDFTextStripper { // store ypos of the char if it is not empty if (current_y > this.max_character_ypos) { this.max_character_ypos = current_y; + }*/ + + if (pageRotation == 0) { + current_y = text.getY(); + } + if (pageRotation == 90) { + current_y = text.getX(); + } + if (pageRotation == 180) { + float page_height = this.getCurrentPage().findMediaBox().getHeight(); + current_y = page_height - text.getY(); + } + if (pageRotation == 270) { + float page_height = this.getCurrentPage().findMediaBox().getHeight(); + current_y = page_height - text.getX(); + } + + if (current_y > this.effectivePageHeight) { + // logger_.debug("character is below footer_line. footer_line = " + + // this.footer_line + ", text.character=" + character + ", y=" + + // current_y); + return; } + // store ypos of the char if it is not empty + if (current_y > this.max_character_ypos) { + this.max_character_ypos = current_y; + } } // use this funtion getting an unsorted text output -- cgit v1.2.3