PDF Permissions not set correctly

Hi,

I want to disallow everything but modifying annotations in a PDF.

However, when I follow the instructions in the API reference, the PDFs generated allow annotations AND filling in form fields and signing.

Here is the code being used:

// Create encryption details and set owner password.
PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", "password", PdfEncryptionAlgorithm.RC_4_128);

// Start by disallowing all permissions.
encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);

// Extend permissions to allow modifying annotations.
encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS);
saveOptions.setEncryptionDetails(encryptionDetails);

// Render the document to PDF format with the specified permissions.
doc.save("output.pdf", saveOptions);

I note that the API docs for Class PdfPermissions under static final int FILL_IN:

Allows filling in forms and signing the document. When using RC4 40-bit encryption, this option is ignored and filling in form is allowed whenever MODIFY_ANNOTATIONS is set.

So it seems like the Aspose software is acting as if the document is being encrypted with 40-bit encryption.

Here is are the permissions on the output document as shown in Acrobat DC:

Screen Shot 2019-07-16 at 6.55.09 PM.jpg (188.4 KB)

Any guesses, Aspose team, as to what is going on?

@jaredseehafer,

Thanks for your inquiry. Have you tried the latest version of Aspose.Words for Java i.e. 19.7 on your end? In case the problem still remains, please ZIP and upload your input Word document and Aspose.Words generated PDF file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

@awais.hafeez

Yes, I believe so. Here’s the maven for this app

<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words</artifactId>
<version>19.7</version>
<classifier>jdk17</classifier>
</dependency>

I have attached the Word docx and pdf to the zip in this message.

Note, this may be relevant: setPreserveFormFields is set to true

Archive.zip (68.7 KB)

@jaredseehafer,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-18898. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

@jaredseehafer,

Unfortunately, the description for PdfPermissions enum in Aspose.Words is currently inaccurate. Permissions for modifying annotations, filling in form fields and signing can only be assigned together and it is not possible to allow only to modify annotations. Here is a permission table from PDF specification:

Bit position Meaning Related value in Aspose.Words
3 Security handlers of revision 2) Print the document.(Security handlers of revision 3 or greater) Print the document (possibly not at the highest quality level, depending on whether bit 12 is also set). Printing
4 Modify the contents of the document by operations other than those controlled by bits 6, 9, and 11. ModifyContents
5 (Security handlers of revision 2) Copy or otherwise extract text and graphics from the document, including extracting text and graphics (in support of accessibility to users with disabilities or for other purposes). (Security handlers of revision 3 or greater) Copy or otherwise extract text and graphics from the document by operations other than that controlled by bit 10. ContentCopy
6 Add or modify text annotations, fill in interactive form fields, and, if bit 4 is also set, create or modify interactive form fields (including signature fields). ModifyAnnotations
9 Security handlers of revision 3 or greater) Fill in existing interactive form fields (including signature fields), even if bit 6 is clear. FillIn
10 (Security handlers of revision 3 or greater) Extract text and graphics (in support of accessibility to users with disabilities or for other purposes). ContentCopyForAccessibility
11 (Security handlers of revision 3 or greater) Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if bit 4 is clear. DocumentAssembly
12 (Security handlers of revision 3 or greater) Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this bit is clear (and bit 3 is set), printing is limited to a low-level representation of the appearance, possibly of degraded quality. HighResolutionPrinting

In the table “Security handlers of revision 2” corresponds to PdfEncryptionAlgorithm.RC4_40 and “Security handlers of revision 3 or greater” corresponds to PdfEncryptionAlgorithm.RC4_128.

We will work on the updating the description in Aspose.Words API for the PdfPermissions enum. We will keep you posted on any further updates.

The issues you have found earlier (filed as WORDSNET-18898) have been fixed in this Aspose.Words for Java 22.3 update.