diff options
author | Andreas Abraham <andreas.abraham@egiz.gv.at> | 2019-12-02 12:54:22 +0100 |
---|---|---|
committer | Andreas Abraham <andreas.abraham@egiz.gv.at> | 2019-12-02 12:54:22 +0100 |
commit | 44256e68fc579cb804d56d1fb5525c6c29d8c38b (patch) | |
tree | cbb173b3db8b2c1c3b8fb46f9aef3f7360c92742 /pdf-over-signer/pdf-over-sigpdfas4/src/main | |
parent | eb8993049ab6341152daa0f2e6a0650be38e8843 (diff) | |
download | pdf-over-44256e68fc579cb804d56d1fb5525c6c29d8c38b.tar.gz pdf-over-44256e68fc579cb804d56d1fb5525c6c29d8c38b.tar.bz2 pdf-over-44256e68fc579cb804d56d1fb5525c6c29d8c38b.zip |
signature placeholder (pdf signature annotation) implemented
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src/main')
-rw-r--r-- | pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index abab10bf..c7dba85f 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -61,7 +61,10 @@ public class PdfAs4Signer implements Signer { String sigProfile = sign_para.getPdfAsSignatureProfileId(); String sigEmblem = (sign_para.getEmblem() == null ? null : sign_para.getEmblem().getFileName()); String sigNote = sign_para.getProperty("SIG_NOTE"); - + String sigPos = null; + if (sign_para.getSignaturePosition() != null) { + sigPos = sign_para.getPdfAsSignaturePosition(); + } PdfAs pdfas = PdfAs4Helper.getPdfAs(); Configuration config = pdfas.getConfiguration(); if (sigEmblem != null && !sigEmblem.trim().isEmpty()) { @@ -76,6 +79,9 @@ public class PdfAs4Signer implements Signer { ByteArrayOutputStream output = new ByteArrayOutputStream(); DataSource input = new ByteArrayDataSource(parameter.getInputDocument().getByteArray()); SignParameter param = PdfAsFactory.createSignParameter(config, input, output); + if (sigPos != null) { + param.setSignaturePosition(sigPos); + } param.setSignatureProfileId(sigProfile); String id = UUID.randomUUID().toString(); param.setTransactionId(id); @@ -128,10 +134,24 @@ public class PdfAs4Signer implements Signer { pdfas.sign(param); SignResultImpl result = new SignResultImpl(); + + if (param.getSignaturePosition() != null) { + TablePos tp = new TablePos(param.getSignaturePosition()); + SignaturePosition sp; + if (tp.isXauto() && tp.isYauto()) + sp = new SignaturePosition(); + else if (tp.isPauto()) + sp = new SignaturePosition(tp.getPosX(), tp.getPosY()); + else + sp = new SignaturePosition(tp.getPosX(), tp.getPosY(), tp.getPage()); + result.setSignaturePosition(sp); + } + result.setSignedDocument(new ByteArrayDocumentSource(sstate.getOutput().toByteArray())); return result; - } - catch (PDFASError e) { + } catch (PdfAsException e) { + throw new SignatureException(e); + } catch (PDFASError e) { throw new SignatureException(e); } } |