pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1826575 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible: PDVisibleSigBuilder.java PDVisibleSignDesigner.java
Date Mon, 12 Mar 2018 16:55:08 GMT
Author: tilman
Date: Mon Mar 12 16:55:07 2018
New Revision: 1826575

URL: http://svn.apache.org/viewvc?rev=1826575&view=rev
Log:
PDFBOX-4146: use same bbox size as image size instead of hard coded values to avoid confusing
Mac Preview app, as suggested by Martin Mancuska

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java?rev=1826575&r1=1826574&r2=1826575&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
Mon Mar 12 16:55:07 2018
@@ -356,11 +356,11 @@ public class PDVisibleSigBuilder impleme
                                         COSName imageName, COSName innerFormName,
                                         PDVisibleSignDesigner properties) throws IOException
     {
-        // 100 means that document width is 100% via the rectangle. if rectangle
-        // is 500px, images 100% is 500px.
-        // String imgFormContent = "q "+imageWidthSize+ " 0 0 50 0 0 cm /" +
-        // imageName + " Do Q\n" + builder.toString();
-        String imgFormContent    = "q " + 100 + " 0 0 50 0 0 cm /" + imageName.getName()
+ " Do Q\n";
+        // Use width and height of BBox as values for transformation matrix.
+        int width = (int) this.getStructure().getFormatterRectangle().getWidth();
+        int height = (int) this.getStructure().getFormatterRectangle().getHeight();
+
+        String imgFormContent    = "q " + width + " 0 0 " + height + " 0 0 cm /" + imageName.getName()
+ " Do Q\n";
         String holderFormContent = "q 1 0 0 1 0 0 cm /" + innerFormName.getName() + " Do
Q\n";
         String innerFormContent  = "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /" + imageFormName.getName()
+ " Do Q\n";
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java?rev=1826575&r1=1826574&r2=1826575&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java
Mon Mar 12 16:55:07 2018
@@ -281,6 +281,8 @@ public class PDVisibleSignDesigner
     {
         imageHeight += (imageHeight * percent) / 100;
         imageWidth += (imageWidth * percent) / 100;
+        formatterRectangleParameters[2] = (int) imageWidth.floatValue();
+        formatterRectangleParameters[3] = (int) imageHeight.floatValue();
         return this;
     }
 
@@ -354,6 +356,7 @@ public class PDVisibleSignDesigner
     public PDVisibleSignDesigner width(float width)
     {
         this.imageWidth = width;
+        this.formatterRectangleParameters[2] = (int) width;
         return this;
     }
 
@@ -374,6 +377,7 @@ public class PDVisibleSignDesigner
     public PDVisibleSignDesigner height(float height)
     {
         this.imageHeight = height;
+        this.formatterRectangleParameters[3] = (int) height;
         return this;
     }
 
@@ -448,6 +452,8 @@ public class PDVisibleSignDesigner
         this.image = image;
         imageHeight = (float) image.getHeight();
         imageWidth = (float) image.getWidth();
+        formatterRectangleParameters[2] = image.getWidth();
+        formatterRectangleParameters[3] = image.getHeight();
     }
 
     /**



Mime
View raw message