PDF - Encrypt

Declaration

<AMPDF ACTIVITY="encrypt" SESSION="text" SOURCE="text" PASSWORD="encrypted text" SAVETYPE="text (options)" DESTINATION="text" PDFDOCUMENTFROM="text (options)" NEWPDF="text" OVERWRITE="YES/NO" CREATEEMPTY="YES/NO" OPENPASSWORD="text (encrypted)" ENCRYPT="text (options)" PERMISSION="YES/NO" PERMISSIONPASSWORD="text (options)" PRINT="text (options)" CHANGE="text" COPY="text (options)/>

Related Topics

Description

Encrypts and password protects a PDF file to limit access and restrict certain features, such as printing or editing.

Practical Usage

Used to protect a PDF file and restrict the way it is used. For example, you can prevent others from editing and copying information, or fine-tune file permissions to limit other activities like printing, commenting, form filling, and adding pages.

Parameters

Resource

Property Type Required Default Markup Description
Resource --- --- --- --- Specifies the source of the PDF file. The available options are:
  • File (default) - The source derives from a PDF file located on the system. This option is normally selected if only a single activity is required to complete the operation.
  • Session - The source PDF is obtained from a pre-configured session created in an earlier step with the use of the PDF - Create session activity. This option is normally selected if a combination of related activities is required to complete an operation. Consolidating several activities to a single session can eliminate redundancy. Moreover, a single task supports multi-session executions which can improve efficiency and speed up production.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Session Text Yes, if Resource is set to Session PDFSession1 SESSION="mySession" The existing session to associate with this activity. This parameter becomes active and is required if the Resource parameter is set to Session.
Use Text (options) Yes, if Resource is set to File Existing PDF
  • PDFDOCUMENTFROM="existing_file"
  • PDFDOCUMENTFROM="new_file"
Specifies whether to add attachments to an existing or newly-created PDF file.  This parameter becomes active and is required if the Resource parameter is set to File. The available options are:
  • Existing PDF (default) - Attachments are added to an existing PDF file.
  • New PDF - Attachments are added to a newly-created PDF file.
Source PDF Text Yes, if Use is set to Existing PDF (Empty) SOURCE="C:\PDFFileName.pdf" The path and file name of PDF to encrypt. This parameter becomes active and is required if the Use parameter is set to Existing PDF.
Password (optional) Text No (Empty) PASSWORD="encrypted" The password required to open the existing PDF file (if required). This parameter becomes active if the Use parameter is set to Existing PDF.
On completion Text (options) Yes, if Use is set to Existing PDF Save
  • SAVETYPE="save"
  • SAVETYPE="do_not_save"
  • SAVETYPE="save_as"
Specifies how changes to the PDF file are saved upon completion of this activity. This parameter becomes active and is required if the Use parameter is set to Existing PDF. The available options are:
  • Save (default) - Changes are saved under the PDF file's original file name.
  • Do not save changes - Any changes made to the existing PDF file are not saved.
  • Save As - Changes are saved to a new path and file name.
Destination PDF Text Yes, if On completion is set to Save as (Empty) DESTINATION="C:\PDFFileName.pdf" The path and file name where the modified existing PDF file is stored. This parameter becomes active and is required if the On completion parameter is set to Save as.
New PDF Text Yes, if Use is set to New PDF (Empty) NEWPDF="C:\PDFFileName.pdf" The path and file name where the newly-generated PDF file is stored. This parameter becomes active and is required if the Use parameter is set to New PDF.
Overwrite if PDF already exists Yes/No No No OVERWRITE="YES" If selected, a PDF file with the same filename in the destination folder is overwritten when this activity runs. If disabled (default), a PDF file with the same filename in the destination folder is not overwritten, however, a runtime error occurs as a result.
Create empty PDF file Yes/No No No CREATEEMPTY="YES" If selected, the activity creates an empty, single-page PDF file. This parameter becomes active if the Use parameter is set to New PDF.

Security

Property Type Required Default Markup Description
Document open password Text Yes (Empty) OPENPASSWORD="encrypted text" The password required to open the document.
Encryption level Text (options) No 256-bit AES
  • ENCRYPT="AES_256"
  • ENCRYPT="AES_128"
  • ENCRYPT="RC4_128"
  • ENCRYPT="RC4_40"
Specifies the encryption algorithm to use to encrypt the document. PDF encryption makes use of two algorithms; RC4, a symmetric stream cipher, and AES (Advanced Encryption Standard), a more modern block cipher. The available options are:
  • 256-bit AES (default)
  • 128-bit AES
  • 128-bit RC4
  • 40-bit RC4

Permissions

Property Type Required Default Markup Description
Restrict editing and printing of the document Yes/No No No PERMISSION="YES" If set to YES (enabled), restrictions will be applied to the editing and printing of the document. Also restricts access to the PDF file’s security settings. If the file is opened in Adobe Acrobat, the user can view the file but must enter the specified Permissions password in order to change the file’s Security and Permissions settings. If the file is opened in Illustrator, Photoshop, or InDesign, the user must enter the Permissions password, since it is not possible to open the file in a view only mode. If set NO (disabled), no restrictions are applied to the editing and printing of the document. This parameter is set to NO (disabled) by default.
Change permission password Text Yes, if Restrict editing and printing of the document is set to YES (Empty) PERMISSIONPASSWORD="encrypted" The password required to change the permission settings. If this parameter is empty, the user must enter the password entered in the Document open password parameter. This parameter becomes active and is required if the Restrict editing and printing of the document parameter is set to YES.
Printing allowed Text (options) No None
  • PRINT="none"
  • PRINT="low_resolution"
  • PRINT="high_resolution"
Specifies the type of printing allowed for the PDF file. The available options are:
  • None (default) - Prevents users from printing the document.
  • Low resolution (150 dpi) - Lets users print at no higher than 150 dpi resolution. Printing may be slower because each page is printed as a bitmap image.
  • High resolution - Lets users print at any resolution, directing high-quality vector output to PostScript and other printers that support advanced high-quality printing features.
Changes allowed Text (options) No None
  • CHANGE="none"
  • CHANGE="insert_delete_rotate"
  • CHANGE="form"
  • CHANGE="comment"
  • CHANGE="extract"
Specifies which editing actions are allowed in the PDF file. The available options are:
  • None (default) - Prevents users from making any changes to the file, such as filling in form fields and adding comments.
  • Inserting, Deleting and Rotating pages - Grants users permission to insert, delete, and rotate pages.
  • Filling in form fields and signing existing signature fields - Grants users permission to fill in fields in interactive forms and add digital signatures to existing signature fields.
  • Commenting, filling in form fields, and signing existing signature fields - Grants users permissions to edit the document, create and fill in form fields, and add comments and digital signatures.
  • Any Except Extracting Pages - Grants users permissions to make any edit to the file, with the exception of extracting pages.
Enable copying of text, images and other content Text No Not selected COPY="copy" If selected, users are granted permission to copy text, images, and other content.
Enable text access for screen reader devices for the visually impaired Text No Selected CHANGE="form" If selected, grants visually impaired users permission to read the document with screen readers, but doesn’t allow users to copy or extract the document’s contents.

Description

Error Causes

On Error

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description

This sample task encrypts a PDF file and then saves it using a different file name.

Copy
<AMPDF ACTIVITY="encrypt" SOURCE="C:\Temp\MyDocument.pdf" SAVETYPE="save_as" DESTINATION="C:\Temp\MyNewDocument.pdf" OPENPASSWORD="AM2X8RGOSnCwfUrxCM5UcK19Q==aME" ENCRYPT="AES_128" PERMISSION="YES" PERMISSIONPASSWORD="AM2X8RGOSnCwfUrxCM5UcK19Q==aME" PRINT="high_resolution" CHANGE="extract" />