summaryrefslogtreecommitdiff
path: root/pdf-over-signer/src/main/java/at/asit/pdfover
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-over-signer/src/main/java/at/asit/pdfover')
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java15
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java1
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java12
3 files changed, 16 insertions, 12 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 78dda185..e3c9d3d3 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
@@ -80,6 +80,9 @@ 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 signature profile in use */
public Profile signatureProfile = Profile.getDefaultProfile();
@@ -103,15 +106,15 @@ public class PdfAs4SignatureParameter {
}
if (this.signatureProfile == Profile.BASE_LOGO)
{
- int emblemWidth = (this.emblem != null) ? this.emblem.getWidth() : 65;
- int emblemHeight = (this.emblem != null) ? this.emblem.getHeight() : 65;
+ 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 = 65.0;
- double targetHeight = 65.0;
+ double targetWidth = this.targetLogoSize;
+ double targetHeight = this.targetLogoSize;
if (aspectRatio < 1)
- targetWidth = 65.0 * aspectRatio;
+ targetWidth *= aspectRatio;
else
- targetHeight = 65.0 / aspectRatio;
+ targetHeight /= 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);
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java
index b944bf24..facdd47e 100644
--- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java
+++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java
@@ -16,6 +16,7 @@ public final class PdfAs4SignaturePlaceholder implements Runnable {
.comparing(PdfAs4SignatureParameter::getPdfAsSignatureProfileId)
.thenComparing((p) -> { return (p.emblem != null) ? p.emblem.getOriginalFileHash() : ""; })
.thenComparing((p) -> { return p.signatureNote; }, Comparator.nullsFirst(String::compareTo))
+ .thenComparing((p) -> { return p.targetLogoSize; })
);
/**
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 628b5c11..e8933e1d 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
@@ -67,15 +67,15 @@ public class PdfAs4Signer {
// 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;
+ 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 = 65.0;
- double targetHeight = 65.0;
+ double targetWidth = parameter.targetLogoSize;
+ double targetHeight = parameter.targetLogoSize;
if (aspectRatio < 1)
- targetWidth = 65.0 * aspectRatio;
+ targetWidth *= aspectRatio;
else
- targetHeight = 65.0 / aspectRatio;
+ targetHeight /= 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);