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 2021/07/22 15:49:48 UTC
svn commit: r1891725 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
Author: tilman
Date: Thu Jul 22 15:49:48 2021
New Revision: 1891725
URL: http://svn.apache.org/viewvc?rev=1891725&view=rev
Log:
PDFBOX-5243: reassign annotations AFTER the element has been added because the early setAnnotation "broke" the COSArrayList "backed by" behavior of the list
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=1891725&r1=1891724&r2=1891725&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 Thu Jul 22 15:49:48 2021
@@ -429,11 +429,6 @@ public class PDDocument implements Close
// Create Annotation / Field for signature
List<PDAnnotation> annotations = page.getAnnotations();
- // Make /Annots a direct object to avoid problem if it is an existing indirect object:
- // it would not be updated in incremental save, and if we'd set the /Annots array "to be updated"
- // while keeping it indirect, Adobe Reader would claim that the document had been modified.
- page.setAnnotations(annotations);
-
// Get the annotations of the page and append the signature-annotation to it
// 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 &&
@@ -452,6 +447,13 @@ public class PDDocument implements Close
annotations.add(widget);
}
}
+
+ // Make /Annots a direct object by reassigning it,
+ // to avoid problem if it is an existing indirect object:
+ // it would not be updated in incremental save, and if we'd set the /Annots array "to be updated"
+ // while keeping it indirect, Adobe Reader would claim that the document had been modified.
+ page.setAnnotations(annotations);
+
page.getCOSObject().setNeedToBeUpdated(true);
}