Skip to main content

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:

  1. Validates that the input PDF path is not empty
  2. Loads the PDF document
  3. Sets access permissions (printing, content extraction, and modification are disabled)
  4. Retrieves the password
  5. Creates a StandardProtectionPolicy with the password
  6. Sets encryption key length to 256 bits
  7. Adds password protection to the PDF
  8. Saves the encrypted PDF to the specified location or overwrites the original
  9. 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