setEncryption
Encrypts the specified PDF file and stores the result into the variable context. The type of encryption used is 128-bit RC4.
This command has various attributes allowing the restrictions placed on users viewing the document to be configured. All restrictions are active by default and by giving the "allow"-prefixed attributes values resolving to a Boolean true
, viewers of the document are given more permissions.
Parent commands
exportPDF
Optional. Allows the PDF produced by the parent command to be automatically set as the target of encryption, lessening required attribute values.
Attributes
var | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | No |
Defines the name of the variable holding the encrypted PDF File. If this command is a child of the |
value | ||
---|---|---|
Required | Value type | EL-evaluated |
No | File | Yes |
Defines the document to encrypt. The resolved value should be a PDF file. If this command is a child of the |
userPassword | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
The resolved String is set as the user password for the encrypted document. Inputting the user password allows the viewer to open the encrypted document with all restrictions set on it intact. The user password may also be undefined, which allows anyone to view the document with its restrictions. |
ownerPassword | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
The resolved String is set as the owner password for the encrypted document. Inputting the owner password allows the document to be viewed without any of its restrictions. If left undefined, the owner password is set to be a randomly generated and complex string, making it practically impossible to view the document without the restrictions. |
allowAssembly | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the value of this attribute resolves to |
allowCopying | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the value of this attribute resolves to |
allowDegradedPrinting | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the value of this attribute resolves to |
allowFillIn | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the resolved value of this attribute is |
allowAnnotationModification | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the resolved value of this attribute is |
allowContentModification | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the resolved value of this attribute is |
allowPrinting | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the resolved value of this attribute is |
allowScreenReaders | ||
---|---|---|
Required | Value type | EL-evaluated |
No | Boolean | Yes |
If the resolved value of this attribute is |
Examples
The setEncryption
command allows easy encryption of a PDF document. In its simplest form, it can be used without any attribute values as a child of an exportPDF
command.
<exportPDF var="pdfDoc" document="${composedDoc}"><setEncryption>
This results in the exported PDF getting all possible restrictions and no way to view it without them. If the document should be possible to viewed without the restrictions, set a value for the ownerPassword
attribute. Users that input this password can then view the document without the restrictions.
<exportPDF var="pdfDoc" document="${composedDoc}"><setEncryption ownerPassword="${ownerPass}">
If the document's viewers should be more limited, set a value for the userPassword
attribute. Now users that do not know this password cannot even view the document.
<setEncryption var="encryptedPDF" value="${pdfDoc}" userPassword="${userPass}">