diff options
3 files changed, 36 insertions, 0 deletions
diff --git a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Emblem.java b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Emblem.java index bd0ef4d9..4c093d29 100644 --- a/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Emblem.java +++ b/pdf-over-signator/src/main/java/at/asit/pdfover/signator/Emblem.java @@ -58,6 +58,10 @@ public class Emblem { private String fileName = null; + // TODO actual values + public int getWidth() { return 190; } + public int getHeight() { return 96; } + /** * Constructor * @param filename 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()); |