diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-05-06 13:25:43 +0200 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-05-06 13:25:43 +0200 |
commit | 98a8921b697e2b03c3f1a873ec1dadd02f954aa6 (patch) | |
tree | 51c648731b1c934ac59ce036cd604178f72addf6 | |
parent | a84fecfd384373402a23ae3153ccce55cef73cb6 (diff) | |
download | pdf-as-4-98a8921b697e2b03c3f1a873ec1dadd02f954aa6.tar.gz pdf-as-4-98a8921b697e2b03c3f1a873ec1dadd02f954aa6.tar.bz2 pdf-as-4-98a8921b697e2b03c3f1a873ec1dadd02f954aa6.zip |
Fixed Positioning on empty page with only annotation
5 files changed, 19 insertions, 68 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java index 854559d2..c74b15b0 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java @@ -40,6 +40,7 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocumentCatalog; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageNode; +import org.apache.pdfbox.pdmodel.PDResources; import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent; import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg; import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; @@ -256,6 +257,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { PDPage lastPage = kids.get(last); rootPages.getCOSObject().setNeedToBeUpdate(true); PDPage p = new PDPage(lastPage.findMediaBox()); + p.setResources(new PDResources()); doc.addPage(p); } 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 e482d50c..f2cd4085 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 @@ -538,10 +538,10 @@ public class PDFPage extends PDFTextStripper { public void processAnnotation(PDAnnotation anno) { float current_y = anno.getRectangle().getLowerLeftY(); - int pageRotation = this.getCurrentPage().findRotation(); + int pageRotation = anno.getPage().findRotation(); // logger_.debug("PageRotation = " + pageRotation); if (pageRotation == 0) { - float page_height = this.getCurrentPage().findMediaBox().getHeight(); + float page_height = anno.getPage().findMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getLowerLeftY(); } if (pageRotation == 90) { @@ -551,7 +551,7 @@ public class PDFPage extends PDFTextStripper { current_y = anno.getRectangle().getUpperRightY(); } if (pageRotation == 270) { - float page_height = this.getCurrentPage().findMediaBox().getHeight(); + float page_height = anno.getPage().findMediaBox().getHeight(); current_y = page_height - anno.getRectangle().getUpperRightX(); } diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java index 3f5e67fc..808efbe4 100644 --- a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java +++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFUtilities.java @@ -82,19 +82,22 @@ public abstract class PDFUtilities { try { PDFPage my_page = new PDFPage(effectivePageHeight, legacy32); PDResources resources = page.findResources(); - COSStream stream = page.getContents().getStream(); - // List<PDThreadBead> articles = page.getThreadBeads(); - // my_page.processMyPage(page); - my_page.processStream(page, resources, stream); - + if (page.getContents() != null) { + COSStream stream = page.getContents().getStream(); + // List<PDThreadBead> articles = page.getThreadBeads(); + // my_page.processMyPage(page); + my_page.processStream(page, resources, stream); + } if (!legacy32) { - Iterator<PDAnnotation> annotationsIt = page.getAnnotations() - .iterator(); + if (page.getAnnotations() != null) { + Iterator<PDAnnotation> annotationsIt = page + .getAnnotations().iterator(); - while (annotationsIt.hasNext()) { - PDAnnotation annotation = annotationsIt.next(); - if(!annotation.isInvisible()) { - my_page.processAnnotation(annotation); + while (annotationsIt.hasNext()) { + PDAnnotation annotation = annotationsIt.next(); + if (!annotation.isInvisible()) { + my_page.processAnnotation(annotation); + } } } } diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSignParameters.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSignParameters.java deleted file mode 100644 index 4658372b..00000000 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSignParameters.java +++ /dev/null @@ -1,43 +0,0 @@ -package at.gv.egiz.pdfas.web.ws; - -import java.io.Serializable; - -public class PDFASSignParameters implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -2375108993871456465L; - - public enum Connector { - JKS, - MOA - } - - Connector connector; - String position; - String profile; - - - public Connector getConnector() { - return connector; - } - public void setConnector(Connector connector) { - this.connector = connector; - } - public String getPosition() { - return position; - } - public void setPosition(String position) { - this.position = position; - } - public String getProfile() { - return profile; - } - public void setProfile(String profile) { - this.profile = profile; - } - - - -} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigning.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigning.java deleted file mode 100644 index 0b75c0e0..00000000 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigning.java +++ /dev/null @@ -1,11 +0,0 @@ -package at.gv.egiz.pdfas.web.ws; - -import javax.jws.WebService; -import javax.jws.soap.SOAPBinding; -import javax.jws.soap.SOAPBinding.Style; - -@WebService -@SOAPBinding(style = Style.RPC) -public interface PDFASSigning { - public byte[] signPDFDokument(byte[] inputDocument, PDFASSignParameters parameters); -} |