You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2016/11/02 18:25:29 UTC

svn commit: r1767752 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Author: tilman
Date: Wed Nov  2 18:25:29 2016
New Revision: 1767752

URL: http://svn.apache.org/viewvc?rev=1767752&view=rev
Log:
PDFBOX-3547: in case of an existing field keep the original rect, as suggested by Lonzak

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1767752&r1=1767751&r2=1767752&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Wed Nov  2 18:25:29 2016
@@ -308,6 +308,9 @@ public class PDDocument implements Close
             sigObject.getCOSObject().setNeedToBeUpdated(true);
         }
 
+        // TODO This "overwrites" the settings of the original signature field which might not be intended by the user
+        // better make it configurable (not all users need/want PDF/A but their own setting):
+
         // to conform PDF/A-1 requirement:
         // The /F key's Print flag bit shall be set to 1 and 
         // its Hidden, Invisible and NoView flag bits shall be set to 0
@@ -477,7 +480,13 @@ public class PDDocument implements Close
         // Read and set the rectangle for visual signature
         COSArray rectArray = (COSArray) annotDict.getDictionaryObject(COSName.RECT);
         PDRectangle rect = new PDRectangle(rectArray);
-        signatureField.getWidgets().get(0).setRectangle(rect);
+        PDRectangle existingRectangle = signatureField.getWidgets().get(0).getRectangle();
+
+        //in case of an existing field keep the original rect
+        if (existingRectangle == null || existingRectangle.getCOSArray().size() != 4)
+        {
+            signatureField.getWidgets().get(0).setRectangle(rect);
+        }
     }
 
     private void assignAppearanceDictionary(PDSignatureField signatureField, COSDictionary apDict)