From d1bb2fc2f16d9d783bfec6e87eba8af407712db3 Mon Sep 17 00:00:00 2001 From: afitzek Date: Tue, 27 Nov 2012 07:31:53 +0000 Subject: Fixed error in signature placement for landscape format git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@921 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/pdf/PDFPage.java | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java index 6ac0900..a0311da 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFPage.java @@ -117,9 +117,31 @@ public class PDFPage extends PDFTextStripper */ protected void showCharacter(TextPosition text) { - final float current_y = text.getY(); + float current_y = text.getY(); final String character = text.getCharacter(); + int pageRotation = page.findRotation(); + //logger_.debug("PageRotation = " + pageRotation); + if (pageRotation == 0) + { + current_y = text.getY(); + } + if (pageRotation == 90) + { + current_y = text.getX(); + } + if (pageRotation == 180) + { + float page_height = page.findMediaBox().getHeight(); + current_y = page_height - text.getY(); + } + if (pageRotation == 270) + { + float page_height = page.findMediaBox().getHeight(); + current_y = page_height - text.getX(); + } + + if (current_y > this.footer_line) { //logger_.debug("character is below footer_line. footer_line = " + this.footer_line + ", text.character=" + character + ", y=" + current_y); @@ -134,7 +156,7 @@ public class PDFPage extends PDFTextStripper // System.err.println(character + "|" + current_y); } - //logger_.debug("text.character=" + character + ", y=" + current_y); + //logger_.error("text.character=" + character + ", y=" + current_y + " max_c=" + this.max_character_ypos); // System.err.println(character + "|" + current_y); } @@ -160,7 +182,7 @@ public class PDFPage extends PDFTextStripper { max_ypos = this.max_image_ypos; } - + //logger_.error("max len=" + max_ypos); return max_ypos; } @@ -170,7 +192,7 @@ public class PDFPage extends PDFTextStripper public void process(PDFOperator operator, List arguments) throws IOException { COSName name = (COSName) arguments.get(0); - //logger_.debug(""); + //logger_.error(""); // PDResources res = context.getResources(); @@ -181,12 +203,13 @@ public class PDFPage extends PDFTextStripper COSStream cos_stream = stream.getStream(); COSName subtype = (COSName) cos_stream.getDictionaryObject(COSName.SUBTYPE); + //logger_.error(""); if (subtype.equals(COSName.IMAGE)) { - logger_.debug("XObject Image"); + //logger_.error("XObject Image"); Matrix ctm = context.getGraphicsState().getCurrentTransformationMatrix(); - logger_.debug("ctm = " + ctm); + //logger_.debug("ctm = " + ctm); Pos [] coordinates = new Pos [] { new Pos(0, 0, 1), -- cgit v1.2.3