aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox/src/main/java/at/knowcenter/wag
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-04-12 14:56:05 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-04-12 14:56:05 +0200
commit8998df18e776b4bf17a4c731e0b9c3aad926ca6d (patch)
tree1ae0bbf81c186096b9491ab23c6e2948829c8abf /pdf-as-pdfbox/src/main/java/at/knowcenter/wag
parent98076fc60c31be00584c81d4ce7c2ef29d2c7eb2 (diff)
downloadpdf-as-4-8998df18e776b4bf17a4c731e0b9c3aad926ca6d.tar.gz
pdf-as-4-8998df18e776b4bf17a4c731e0b9c3aad926ca6d.tar.bz2
pdf-as-4-8998df18e776b4bf17a4c731e0b9c3aad926ca6d.zip
Changed automatic positioning to handle annotation partly above the footerline, introduced legacy40.pos option to disable the change
Diffstat (limited to 'pdf-as-pdfbox/src/main/java/at/knowcenter/wag')
-rw-r--r--pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java19
-rw-r--r--pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java8
2 files changed, 22 insertions, 5 deletions
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;
}
diff --git a/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java b/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java
index 808efbe4..cf53025b 100644
--- a/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java
+++ b/pdf-as-pdfbox/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java
@@ -68,19 +68,19 @@ import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
*/
public abstract class PDFUtilities {
public static float calculatePageLength(PDDocument document, int page,
- float effectivePageHeight, /* int pagerotation, */boolean legacy32)
+ float effectivePageHeight, /* int pagerotation, */boolean legacy32, boolean legacy40)
throws PDFIOException {
// int last_page_id = document.getNumberOfPages();
List<?> allPages = document.getDocumentCatalog().getAllPages();
PDPage pdpage = (PDPage) allPages.get(page);
// pdpage.setRotation(pagerotation);
- return calculatePageLength(pdpage, effectivePageHeight, legacy32);
+ return calculatePageLength(pdpage, effectivePageHeight, legacy32, legacy40);
}
public static float calculatePageLength(PDPage page,
- float effectivePageHeight, boolean legacy32) throws PDFIOException {
+ float effectivePageHeight, boolean legacy32, boolean legacy40) throws PDFIOException {
try {
- PDFPage my_page = new PDFPage(effectivePageHeight, legacy32);
+ PDFPage my_page = new PDFPage(effectivePageHeight, legacy32, legacy40);
PDResources resources = page.findResources();
if (page.getContents() != null) {
COSStream stream = page.getContents().getStream();