From 58433c6fd73dd26488be3fb975946d1c447d0b2f Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Tue, 9 Aug 2022 14:39:21 +0200 Subject: add logo size to config file --- .../configuration/SimpleConfigurationComposite.java | 1 + .../gui/workflow/config/ConfigurationDataInMemory.java | 3 +++ .../pdfover/gui/workflow/config/ConfigurationManager.java | 14 ++++++++++++++ .../asit/pdfover/gui/workflow/states/PositioningState.java | 1 + .../pdfover/gui/workflow/states/PrepareSigningState.java | 2 ++ 5 files changed, 21 insertions(+) (limited to 'pdf-over-gui/src') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java index ea26cd9a..5a19c59b 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java @@ -427,6 +427,7 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase { param.signatureLanguage = this.configurationContainer.signatureLocale.getLanguage(); param.enablePDFACompat = this.configurationContainer.signaturePDFACompat; + param.targetLogoSize = this.configurationContainer.logoOnlyTargetSize; String image = this.configurationContainer.getEmblemPath(); if (image != null && !image.trim().isEmpty()) { param.emblem = new Emblem(image); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java index 51b48c09..9fda1f1f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationDataInMemory.java @@ -45,6 +45,9 @@ public class ConfigurationDataInMemory { @SuppressWarnings("unused") private static final Logger log = LoggerFactory.getLogger(ConfigurationDataInMemory.class); + /** the emblem size (in mm) for logo only signatures */ + public double logoOnlyTargetSize = Constants.DEFAULT_LOGO_ONLY_SIZE; + /** the emblem File */ protected String emblemFile = null; public String getEmblemPath() { return this.emblemFile; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java index f9981878..4a9a7584 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationManager.java @@ -85,6 +85,11 @@ public class ConfigurationManager { diskConfig.load(new FileInputStream(Constants.CONFIG_DIRECTORY + File.separator + getConfigurationFileName())); setDefaultEmblemPersistent(diskConfig.getProperty(Constants.CFG_EMBLEM)); + try { + String strProp = diskConfig.getProperty(Constants.CFG_LOGO_ONLY_SIZE); + if (strProp != null) + setLogoOnlyTargetSize(Double.parseDouble(strProp)); + } catch (NumberFormatException e) { log.info("Invalid value for CFG_LOGO_ONLY_SIZE ignored.", e); } setDefaultMobileNumberPersistent(diskConfig.getProperty(Constants.CFG_MOBILE_NUMBER)); setRememberMobilePasswordPersistent(Constants.TRUE.equals(diskConfig.getProperty(Constants.CFG_MOBILE_PASSWORD_REMEMBER))); @@ -270,6 +275,7 @@ public class ConfigurationManager { props.setProperty(Constants.CFG_PROXY_PASS, proxyPass); props.setProperty(Constants.CFG_EMBLEM, getDefaultEmblemPersistent()); + props.setProperty(Constants.CFG_LOGO_ONLY_SIZE, Double.toString(getLogoOnlyTargetSize())); props.setProperty(Constants.CFG_SIGNATURE_NOTE, getSignatureNote()); props.setProperty(Constants.CFG_MOBILE_NUMBER, getDefaultMobileNumberPersistent()); if (getRememberMobilePassword()) @@ -512,6 +518,14 @@ public class ConfigurationManager { return emblem; } + public void setLogoOnlyTargetSize(double v) { + this.configuration.logoOnlyTargetSize = v; + } + + public double getLogoOnlyTargetSize() { + return this.configuration.logoOnlyTargetSize; + } + public void setProxyHostPersistent(String host) { if (host == null || host.trim().isEmpty()) { this.configuration.proxyHost = STRING_EMPTY; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 1f23f0ba..2ffb7404 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -117,6 +117,7 @@ public class PositioningState extends State { param.signatureLanguage = config.getSignatureLocale().getLanguage(); param.enablePDFACompat = config.getSignaturePdfACompat(); + param.targetLogoSize = config.getLogoOnlyTargetSize(); PdfAs4SignaturePlaceholder.For(param, (p) -> { this.positionComposite.setPlaceholder( diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index 3ab3fcf8..cc0a83a7 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -150,6 +150,8 @@ public class PrepareSigningState extends State { this.state.signatureParameter.signatureProfile = configuration.getSignatureProfile(); + this.state.signatureParameter.targetLogoSize = configuration.getLogoOnlyTargetSize(); + this.state.signingState = PdfAs4Signer.prepare(this.state.signatureParameter); } catch (Exception e) { -- cgit v1.2.3