From 209f81ea544762f25aedf10551e33feef74272b5 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Tue, 9 Aug 2022 14:39:01 +0200 Subject: fix scaling mm -> pdf units --- .../at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 9 +++++---- .../src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'pdf-over-signer') 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 e3c9d3d3..745f10ea 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 @@ -36,6 +36,7 @@ import at.gv.egiz.pdfas.lib.api.Configuration; import at.gv.egiz.pdfas.lib.api.PdfAs; import at.gv.egiz.pdfas.lib.api.PdfAsFactory; import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.asit.pdfover.commons.Constants; import at.asit.pdfover.commons.Profile; /** @@ -80,8 +81,8 @@ public class PdfAs4SignatureParameter { /** Whether so look for placeholder signatures or not. */ public boolean searchForPlaceholderSignatures = false; - /** The size to scale the logo to */ - public double targetLogoSize = 65.0; + /** The size to scale the logo to (in mm) */ + public double targetLogoSize = Constants.DEFAULT_LOGO_ONLY_SIZE; /** The signature profile in use */ public Profile signatureProfile = Profile.getDefaultProfile(); @@ -109,8 +110,8 @@ public class PdfAs4SignatureParameter { int emblemWidth = (this.emblem != null) ? this.emblem.getWidth() : 1; int emblemHeight = (this.emblem != null) ? this.emblem.getHeight() : 1; double aspectRatio = ((double)emblemWidth) / emblemHeight; - double targetWidth = this.targetLogoSize; - double targetHeight = this.targetLogoSize; + double targetWidth = this.targetLogoSize * Constants.PDF_UNITS_PER_MM; + double targetHeight = this.targetLogoSize * Constants.PDF_UNITS_PER_MM; if (aspectRatio < 1) targetWidth *= aspectRatio; else 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 e8933e1d..e0790dfc 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 @@ -5,6 +5,7 @@ import java.util.UUID; import javax.activation.DataSource; +import at.asit.pdfover.commons.Constants; import at.asit.pdfover.commons.Profile; import at.asit.pdfover.signator.ByteArrayDocumentSource; import at.asit.pdfover.signator.SignResult; @@ -70,8 +71,8 @@ public class PdfAs4Signer { int emblemWidth = (parameter.emblem != null) ? parameter.emblem.getWidth() : 1; int emblemHeight = (parameter.emblem != null) ? parameter.emblem.getHeight() : 1; double aspectRatio = ((double)emblemWidth) / emblemHeight; - double targetWidth = parameter.targetLogoSize; - double targetHeight = parameter.targetLogoSize; + double targetWidth = parameter.targetLogoSize * Constants.PDF_UNITS_PER_MM; + double targetHeight = parameter.targetLogoSize * Constants.PDF_UNITS_PER_MM; if (aspectRatio < 1) targetWidth *= aspectRatio; else -- cgit v1.2.3