Author: tilman
Date: Mon Sep 1 17:38:33 2025
New Revision: 1928169
Log:
PDFBOX-6058: Preserve Perms dictionary when signing
Modified:
pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
Modified:
pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
==============================================================================
---
pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
Mon Sep 1 17:24:27 2025 (r1928168)
+++
pdfbox/branches/3.0/examples/src/main/java/org/apache/pdfbox/examples/signature/SigUtils.java
Mon Sep 1 17:38:33 2025 (r1928169)
@@ -184,8 +184,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);