Skip to content

Commit 20b6e52

Browse files
committed
PDFBOX-6058: Preserve Perms dictionary when signing
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1928170 13f79535-47bb-0310-9956-ffa450edef68
1 parent 7e03c82 commit 20b6e52

File tree

1 file changed

+6
-2
lines changed
  • examples/src/main/java/org/apache/pdfbox/examples/signature

1 file changed

+6
-2
lines changed

examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ public static void setMDPPermission(PDDocument doc, PDSignature signature, int a
184184

185185
// Catalog
186186
COSDictionary catalogDict = doc.getDocumentCatalog().getCOSObject();
187-
COSDictionary permsDict = new COSDictionary();
188-
catalogDict.setItem(COSName.PERMS, permsDict);
187+
COSDictionary permsDict = catalogDict.getCOSDictionary(COSName.PERMS);
188+
if (permsDict == null)
189+
{
190+
permsDict = new COSDictionary();
191+
catalogDict.setItem(COSName.PERMS, permsDict);
192+
}
189193
permsDict.setItem(COSName.DOCMDP, signature);
190194
catalogDict.setNeedToBeUpdated(true);
191195
permsDict.setNeedToBeUpdated(true);

0 commit comments

Comments
 (0)