diff options
Diffstat (limited to 'pdf-over-signer/src/main/java/at/asit')
-rw-r--r-- | pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 15 | ||||
-rw-r--r-- | pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 17 |
2 files changed, 32 insertions, 0 deletions
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index c6613657..cea41bdd 100644 --- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -98,6 +98,21 @@ public class PdfAs4SignatureParameter { if (sigNote != null) { conf.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote); } + if (this.signatureProfile == Profile.BASE_LOGO) + { + int emblemWidth = (this.emblem != null) ? this.emblem.getWidth() : 65; + int emblemHeight = (this.emblem != null) ? this.emblem.getHeight() : 65; + double aspectRatio = ((double)emblemWidth) / emblemHeight; + double targetWidth = 65.0; + double targetHeight = 65.0; + if (aspectRatio < 1) + targetWidth = 65.0 * aspectRatio; + else + targetHeight = 65.0 / aspectRatio; + conf.setValue("sig_obj." + sigProfile + ".table.main.Style.padding", "0"); + conf.setValue("sig_obj." + sigProfile + ".pos", "w:"+targetWidth+";f:0"); + conf.setValue("sig_obj." + sigProfile + ".table.main.Style.imagescaletofit", targetWidth+";"+targetHeight); + } SignParameter param = PdfAsFactory.createSignParameter(conf, null, null); param.setSignatureProfileId(sigProfile); diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index e4d07b5d..952f1971 100644 --- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -62,6 +62,23 @@ public class PdfAs4Signer { config.setValue("sig_obj." + sigProfile + ".value.SIG_NOTE", sigNote); } + // TODO encapsulate this parameter magic in PdfAs4SignatureParameter + if (parameter.signatureProfile == Profile.BASE_LOGO) + { + int emblemWidth = (parameter.emblem != null) ? parameter.emblem.getWidth() : 65; + int emblemHeight = (parameter.emblem != null) ? parameter.emblem.getHeight() : 65; + double aspectRatio = ((double)emblemWidth) / emblemHeight; + double targetWidth = 65.0; + double targetHeight = 65.0; + if (aspectRatio < 1) + targetWidth = 65.0 * aspectRatio; + else + targetHeight = 65.0 / aspectRatio; + config.setValue("sig_obj." + sigProfile + ".table.main.Style.padding", "0"); + config.setValue("sig_obj." + sigProfile + ".pos", "w:"+targetWidth+";f:0"); + config.setValue("sig_obj." + sigProfile + ".table.main.Style.imagescaletofit", targetWidth+";"+targetHeight); + } + PdfAs4SigningState state = new PdfAs4SigningState(); ByteArrayOutputStream output = new ByteArrayOutputStream(); DataSource input = new ByteArrayDataSource(parameter.inputDocument.getByteArray()); |