Encrypt
Adds password protection to a PDF document.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- PDF File Path - The path to the PDF file that needs to be encrypted.
Options
- Output Path - The path where the encrypted PDF will be saved. If not specified, the original file will be overwritten.
- Password - The password to set for the PDF document.
Output
- result - The result of the encryption operation.
How It Works
The Encrypt node adds password protection to an existing PDF document. When executed, the node:
- Validates that the input PDF path is not empty
- Loads the PDF document
- Sets access permissions (printing, content extraction, and modification are disabled)
- Retrieves the password
- Creates a StandardProtectionPolicy with the password
- Sets encryption key length to 256 bits
- Adds password protection to the PDF
- Saves the encrypted PDF to the specified location or overwrites the original
- Closes the document
Requirements
- A valid PDF file path
- A password to set for encryption
- Sufficient permissions to read the input file and write to the output location
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid PDF File Path
- Missing password
- File I/O errors
- PDF processing errors
Usage Notes
- The encrypted PDF will have restricted permissions (no printing, content extraction, or modification)
- The encryption uses 256-bit key length for strong security
- If no output path is specified, the original file will be overwritten
- The password should be securely stored as it is required for decryption