Author: tilman
Date: Mon Sep 1 17:38:40 2025
New Revision: 1928171
Log:
PDFBOX-6058: Preserve Perms dictionary when signing
Modified:
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
Modified:
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
==============================================================================
---
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
Mon Sep 1 17:38:37 2025 (r1928170)
+++
pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
Mon Sep 1 17:38:40 2025 (r1928171)
@@ -182,8 +182,12 @@ public class SigUtils
// Catalog
COSDictionary catalogDict = doc.getDocumentCatalog().getCOSObject();
- COSDictionary permsDict = new COSDictionary();
- catalogDict.setItem(COSName.PERMS, permsDict);
+ COSDictionary permsDict = catalogDict.getCOSDictionary(COSName.PERMS);
+ if (permsDict == null)
+ {
+ permsDict = new COSDictionary();
+ catalogDict.setItem(COSName.PERMS, permsDict);
+ }
permsDict.setItem(COSName.DOCMDP, signature);
catalogDict.setNeedToBeUpdated(true);
permsDict.setNeedToBeUpdated(true);