diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-04-03 15:38:01 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-04-03 15:47:56 +0200 |
commit | f891dca529c9dc199114ae4f0857d28812315b11 (patch) | |
tree | 66de8c3db33fd05ff8511c9d8252aaef72a6b516 /pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | |
parent | 473f376290dbcaa435f234a9ba48d9bc54946923 (diff) | |
download | pdf-as-4-f891dca529c9dc199114ae4f0857d28812315b11.tar.gz pdf-as-4-f891dca529c9dc199114ae4f0857d28812315b11.tar.bz2 pdf-as-4-f891dca529c9dc199114ae4f0857d28812315b11.zip |
Fixed Positioning to recognize Annotations
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java')
-rw-r--r-- | pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 31 |
1 files changed, 31 insertions, 0 deletions
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 540179b8..e482d50c 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 @@ -64,6 +64,7 @@ import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.common.PDStream; import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject; import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectForm; +import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; import org.apache.pdfbox.util.Matrix; import org.apache.pdfbox.util.PDFOperator; import org.apache.pdfbox.util.PDFTextStripper; @@ -534,4 +535,34 @@ public class PDFPage extends PDFTextStripper { return min; } + public void processAnnotation(PDAnnotation anno) { + float current_y = anno.getRectangle().getLowerLeftY(); + + int pageRotation = this.getCurrentPage().findRotation(); + // logger_.debug("PageRotation = " + pageRotation); + if (pageRotation == 0) { + float page_height = this.getCurrentPage().findMediaBox().getHeight(); + current_y = page_height - anno.getRectangle().getLowerLeftY(); + } + if (pageRotation == 90) { + current_y = anno.getRectangle().getLowerLeftX(); + } + if (pageRotation == 180) { + current_y = anno.getRectangle().getUpperRightY(); + } + if (pageRotation == 270) { + float page_height = this.getCurrentPage().findMediaBox().getHeight(); + current_y = page_height - anno.getRectangle().getUpperRightX(); + } + + if (current_y > this.effectivePageHeight) { + return; + } + + // store ypos of the char if it is not empty + if (current_y > this.max_character_ypos) { + this.max_character_ypos = current_y; + } + } + } |