aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-04-15 16:19:01 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-04-15 16:19:01 +0200
commitc0c25045fafa139a9e6337fd732945ee9cd6318a (patch)
treee5686d80be7040455b1ef57e51dee9f888ab3679 /pdf-as-lib/src/main
parente16e014efea7a220ce984cd038c55b034145e9fe (diff)
downloadpdf-as-4-c0c25045fafa139a9e6337fd732945ee9cd6318a.tar.gz
pdf-as-4-c0c25045fafa139a9e6337fd732945ee9cd6318a.tar.bz2
pdf-as-4-c0c25045fafa139a9e6337fd732945ee9cd6318a.zip
implemented style imageScaleToFit parameter
Diffstat (limited to 'pdf-as-lib/src/main')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFAsVisualSignatureBuilder.java10
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java11
2 files changed, 19 insertions, 2 deletions
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;