Skip to main content
Skip table of contents

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 exportPDF command, this attribute's value may be left undefined in which case the parent command's var is used.

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 exportPDF command, this attribute's value may be left undefined with the exported PDF automatically chosen to be the target of encryption.

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 true, users viewing the document can insert, delete and rotate pages, and create bookmarks and thumbnails.

allowCopying

Required

Value type

EL-evaluated

No

Boolean

Yes

If the value of this attribute resolves to true, users viewing the document can copy its contents to the clipboard.

allowDegradedPrinting

Required

Value type

EL-evaluated

No

Boolean

Yes

If the value of this attribute resolves to true, users viewing the document are allowed to print it at a low resolution.

allowFillIn

Required

Value type

EL-evaluated

No

Boolean

Yes

If the resolved value of this attribute is true, users viewing the document can fill in forms and add digital signatures.

allowAnnotationModification

Required

Value type

EL-evaluated

No

Boolean

Yes

If the resolved value of this attribute is true, users viewing the document can add comments, fill in forms and add digital signatures.

allowContentModification

Required

Value type

EL-evaluated

No

Boolean

Yes

If the resolved value of this attribute is true, users viewing the document can edit the document, fill in forms, and add comments and digital signatures.

allowPrinting

Required

Value type

EL-evaluated

No

Boolean

Yes

If the resolved value of this attribute is true, users viewing the document are allowed to print it at any resolution.

allowScreenReaders

Required

Value type

EL-evaluated

No

Boolean

Yes

If the resolved value of this attribute is true, users viewing the document are allowed to read it with screen readers.

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.

CODE
<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.

CODE
<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.

CODE
<setEncryption var="encryptedPDF" value="${pdfDoc}" userPassword="${userPass}"> 
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.