From cd45da1f83fa5682347e422910dbad8ce4392e69 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Mon, 6 Oct 2014 10:07:34 +0200 Subject: scaling image to keep aspect ratio --- .../stamping/pdfbox/PDFAsVisualSignatureBuilder.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java index e8d1f4c0..00e7e149 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java @@ -589,6 +589,15 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { float origWidth = (float) img.getWidth(); float origHeight = (float) img.getHeight(); + if (table.style != null) { + if (table.style.getImageScaleToFit() != null) { + iwidth = table.style.getImageScaleToFit() + .getWidth(); + iheight = table.style.getImageScaleToFit() + .getHeight(); + } + } + float wfactor = iwidth / origWidth; float hfactor = iheight / origHeight; float scaleFactor = wfactor; @@ -600,16 +609,7 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { .floor((double) (scaleFactor * origWidth)); iheight = (float) Math .floor((double) (scaleFactor * origHeight)); - - if (table.style != null) { - if (table.style.getImageScaleToFit() != null) { - iwidth = table.style.getImageScaleToFit() - .getWidth(); - iheight = table.style.getImageScaleToFit() - .getHeight(); - } - } - + logger.debug("Scaling image to: " + iwidth + " x " + iheight); -- cgit v1.2.3