You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2011/06/28 19:39:27 UTC

svn commit: r1140745 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Author: lehmi
Date: Tue Jun 28 17:39:26 2011
New Revision: 1140745

URL: http://svn.apache.org/viewvc?rev=1140745&view=rev
Log:
PDFBOX-1041: avoid double entries in acroforms when adding a signature as proposed by Thomas Chojecki

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1140745&r1=1140744&r2=1140745&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Tue Jun 28 17:39:26 2011
@@ -438,12 +438,18 @@ public class PDDocument implements Pagea
       
         // Get the annotations of the page and append the signature-annotation to it
         List annotations = page.getAnnotations();
-        if (annotations== null) 
+        if (annotations == null) 
         {
             annotations = new COSArrayList();
+            page.setAnnotations(annotations);
+        }
+        // take care that page and acroforms do not share the same array (if so, we don't need to add it twice)
+        if (!(annotations instanceof COSArrayList) 
+                || !(acroFormFields instanceof COSArrayList) 
+                || !((COSArrayList)annotations).toList().equals(((COSArrayList)acroFormFields).toList()))
+        {
+            annotations.add(signatureField.getWidget());
         }
-        annotations.add(signatureField.getWidget());
-        page.setAnnotations(annotations);
         page.getCOSObject().setNeedToBeUpdate(true);
     }