From e899aad89b109937ec26469829df6f67b759c093 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:06:28 +0000 Subject: upscale placeholder image git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@133 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../signer/pdfas/PdfAsSignatureParameter.java | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit') diff --git a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java index 0af728a1..3ca1ace1 100644 --- a/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas/src/main/java/at/asit/pdfover/signer/pdfas/PdfAsSignatureParameter.java @@ -55,6 +55,8 @@ public class PdfAsSignatureParameter extends SignatureParameter { static final Logger log = LoggerFactory .getLogger(PdfAsSignatureParameter.class); + private static final int PLACEHOLDER_SCALE = 4; + private HashMap genericProperties = new HashMap(); /** @@ -132,8 +134,8 @@ public class PdfAsSignatureParameter extends SignatureParameter { sign_obj.fillValues(' ', true, false); sign_obj.setKZ(BinarySignator_1_1_0.MY_ID); - float width = getPlaceholderDimension().getWidth(); - float height = getPlaceholderDimension().getHeight(); + float width = getPlaceholderDimension().getWidth() * PLACEHOLDER_SCALE; + float height = getPlaceholderDimension().getHeight() * PLACEHOLDER_SCALE; Table table = sign_obj.getAbstractTable(); @@ -202,9 +204,9 @@ public class PdfAsSignatureParameter extends SignatureParameter { if (font_arr.length != 3) { return Font.decode(def); } - return Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], + Font font = Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], font_arr[1])); - + return font.deriveFont((float) font.getSize() * PLACEHOLDER_SCALE); } /** @@ -222,8 +224,9 @@ public class PdfAsSignatureParameter extends SignatureParameter { if (font_arr.length != 3) { return Font.decode(def); } - return Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], + Font font = Font.decode(String.format("%s-%s-%s", font_arr[0], font_arr[2], font_arr[1])); + return font.deriveFont((float) font.getSize() * PLACEHOLDER_SCALE); } @SuppressWarnings("rawtypes") @@ -298,8 +301,8 @@ public class PdfAsSignatureParameter extends SignatureParameter { + "/" + entry.getValue().toString())); } - int imgWidth = 40; - int imgHeight = 40; + int imgWidth = 40 * PLACEHOLDER_SCALE; + int imgHeight = 40 * PLACEHOLDER_SCALE; Image img = image.getScaledInstance(imgWidth, imgHeight, Image.SCALE_SMOOTH); @@ -366,10 +369,10 @@ public class PdfAsSignatureParameter extends SignatureParameter { if (entry.getType() == 0 || entry.getType() == 1) { String fontString = style.getFont(); String[] font_arr = fontString.split(","); - int fontSize = 8; + int fontSize = 8 * PLACEHOLDER_SCALE; if (font_arr.length == 3) { - fontSize = Integer.parseInt(font_arr[1]); + fontSize = Integer.parseInt(font_arr[1]) * PLACEHOLDER_SCALE; } if (rsize < ((style.getPadding() * 2) + fontSize)) { @@ -407,10 +410,10 @@ public class PdfAsSignatureParameter extends SignatureParameter { if (entry.getType() == 0 || entry.getType() == 1) { String fontString = style.getFont(); String[] font_arr = fontString.split(","); - int fontSize = 8; + int fontSize = 8 * PLACEHOLDER_SCALE; if (font_arr.length == 3) { - fontSize = Integer.parseInt(font_arr[1]); + fontSize = Integer.parseInt(font_arr[1]) * PLACEHOLDER_SCALE; } if (rsize < ((style.getPadding() * 2) + fontSize)) { -- cgit v1.2.3