From c0c25045fafa139a9e6337fd732945ee9cd6318a Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 15 Apr 2014 16:19:01 +0200 Subject: implemented style imageScaleToFit parameter --- .../lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java | 10 ++++++++-- .../gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java | 11 +++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'pdf-as-lib/src/main/java') 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 e24ff939..ea26c778 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 @@ -369,10 +369,16 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder { float width = colsSizes[j]; - int size = (int) Math.floor((double) width); + float size = (int) Math.floor((double) width); size -= 2 * padding; logger.debug("Scaling image to: " + size); - + + if(table.style != null) { + if(table.style.getImageScaleToFit() != null) { + size = table.style.getImageScaleToFit().getWidth(); + } + } + PDXObjectImage pdImage = new PDJpeg(template, img); ImageObject image = new ImageObject(pdImage, size); images.put(img_ref, image); diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java index 7274cdf2..1c9ad953 100644 --- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java @@ -251,6 +251,9 @@ public class PDFBoxTable { return c.getStringWidth(string) / 1000 * fontSize; } case Entry.TYPE_IMAGE: + if(style != null && style.getImageScaleToFit() != null) { + return style.getImageScaleToFit().getWidth(); + } return 80.f; case Entry.TYPE_TABLE: PDFBoxTable pdfBoxTable = null; @@ -387,6 +390,11 @@ public class PDFBoxTable { cell.setValue(concatLines(lines)); return fheight * lines.length; case Entry.TYPE_IMAGE: + if(style != null && style.getImageScaleToFit() != null) { + if( style.getImageScaleToFit().getHeight() < width) { + return style.getImageScaleToFit().getHeight(); + } + } return width; case Entry.TYPE_TABLE: PDFBoxTable pdfBoxTable = null; @@ -437,6 +445,9 @@ public class PDFBoxTable { return fheight; } case Entry.TYPE_IMAGE: + if(style != null && style.getImageScaleToFit() != null) { + return style.getImageScaleToFit().getHeight(); + } return 80.f; case Entry.TYPE_TABLE: PDFBoxTable pdfBoxTable = null; -- cgit v1.2.3