aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-pdfbox/src/main/java')
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/positioning/Positioning.java8
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java8
-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
4 files changed, 30 insertions, 13 deletions
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/positioning/Positioning.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/positioning/Positioning.java
index 7aa3fa71..e2f245a7 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/positioning/Positioning.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/positioning/Positioning.java
@@ -77,9 +77,9 @@ public class Positioning {
*/
public static PositioningInstruction determineTablePositioning(
TablePos pos, String signature_type, PDDocument pdfDataSource,
- IPDFVisualObject pdf_table, boolean legacy32) throws PdfAsException {
+ IPDFVisualObject pdf_table, boolean legacy32, boolean legacy40) throws PdfAsException {
return adjustSignatureTableandCalculatePosition(pdfDataSource,
- pdf_table, pos, legacy32);
+ pdf_table, pos, legacy32, legacy40);
}
private static PDRectangle rotateBox(PDRectangle cropBox, int rotation) {
@@ -153,7 +153,7 @@ public class Positioning {
*/
public static PositioningInstruction adjustSignatureTableandCalculatePosition(
final PDDocument pdfDataSource, IPDFVisualObject pdf_table,
- TablePos pos, boolean legacy32) throws PdfAsException {
+ TablePos pos, boolean legacy32, boolean legacy40) throws PdfAsException {
PdfBoxUtils.checkPDFPermissions(pdfDataSource);
// get pages of currentdocument
@@ -265,7 +265,7 @@ public class Positioning {
float pre_page_length = PDFUtilities.calculatePageLength(pdfDataSource,
page - 1, page_height - footer_line, /* page_rotation, */
- legacy32);
+ legacy32, legacy40);
if (pre_page_length == Float.NEGATIVE_INFINITY) {
// we do have an empty page or nothing in area above footerline
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
index 97faf102..6d035b30 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
@@ -35,7 +35,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
-import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.pdfbox.cos.COSArray;
@@ -261,6 +260,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
}
boolean legacy32Position = signatureProfileConfiguration.getLegacy32Positioning();
+ boolean legacy40Position = signatureProfileConfiguration.getLegacy40Positioning();
// create Table describtion
Table main = TableFactory.createSigTable(signatureProfileSettings, MAIN, pdfObject.getStatus(),
@@ -277,7 +277,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
*/
PositioningInstruction positioningInstruction = Positioning.determineTablePositioning(tablePos, "",
- doc, visualObject, legacy32Position);
+ doc, visualObject, legacy32Position, legacy40Position);
logger.debug("Positioning: {}", positioningInstruction.toString());
@@ -722,10 +722,10 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
PositioningInstruction positioningInstruction = null;
if (signaturePosString != null) {
positioningInstruction = Positioning.determineTablePositioning(new TablePos(signaturePosString), "",
- origDoc, visualObject, false);
+ origDoc, visualObject, false, false);
} else {
positioningInstruction = Positioning.determineTablePositioning(new TablePos(), "", origDoc,
- visualObject, false);
+ visualObject, false, false);
}
origDoc.close();
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();