From 03b80912dc888296647412b0276e7610315fef13 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Thu, 4 Aug 2022 13:47:16 +0200 Subject: workaround #110, manually paint a black border --- .../pdfover/signer/pdfas/PdfAs4SignatureParameter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 aba1e9ac..5898d2d1 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 @@ -19,6 +19,8 @@ package at.asit.pdfover.signer.pdfas; import iaik.x509.X509Certificate; +import java.awt.Color; +import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import java.util.HashMap; @@ -99,7 +101,17 @@ public class PdfAs4SignatureParameter { SignParameter param = PdfAsFactory.createSignParameter(conf, null, null); param.setSignatureProfileId(sigProfile); - return pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4); + Image placeholder = pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4); + + // WORKAROUND for #110, manually paint a black border + if (!this.signatureProfileName.equals(Profile.BASE_LOGO.name())) + { + Graphics2D ctx = (Graphics2D)placeholder.getGraphics(); + ctx.setColor(Color.BLACK); + ctx.drawRect(0, 0, placeholder.getWidth(null)-1, placeholder.getHeight(null)-1); + } + + return placeholder; } catch (Exception e) { log.error("Failed to get signature placeholder", e); return new BufferedImage(229, 77, BufferedImage.TYPE_INT_RGB); -- cgit v1.2.3