Encrypt PDF with password
Description
The Encrypt PDF with password activity applies password protection to input PDF files. Passwords are selected using regex-based rules matched against each file name. Files that are already protected are returned unchanged with an error message, while files with no matching rule are skipped and returned unchanged.
Supported Features
- Multiple file processing: Processes each input file independently.
- Regex-based password rules: Match file names and choose the password to apply.
- AES-256 encryption: Uses PDF password encryption with AES 256-bit encryption.
- Already-protected detection: Detects encrypted PDFs and does not re-encrypt them.
- Invalid PDF handling: Reports invalid or corrupt PDF files.
- Unmatched file passthrough: Files without a matching password rule are returned unchanged.
Input
| Type | Required | Description |
|---|---|---|
| Files | Yes | PDF files to encrypt. |
Input Scenarios
1. Unprotected PDF With Matching Rule
{ "Files": [ { "FileName": "invoice-001.pdf", "FullPath": "C:/Work/invoice-001.pdf" } ]}2. Unprotected PDF With No Matching Rule
The file is skipped and returned unchanged.
3. Already Protected PDF
The file is returned unchanged and the activity records Already protected: <file>.
Output
| Field | Type | Description |
|---|---|---|
| Files | Array | Encrypted PDF files, unchanged already-protected files, or unchanged files skipped because no rule matched. |
| Errors | Array | Errors for already protected files, invalid PDFs, missing files, or processing failures. |
Output Behavior
- If at least one file is returned and errors exist, the activity returns success with errors.
- If no files are returned and errors exist, the activity returns failure.
- Encrypted files are written to the workflow base working folder using the original file name.
Configuration Fields
| Field Name | Type | Required | Description |
|---|---|---|---|
| Password rules | Object Array | Yes | List of filename matching rules. Each rule contains FilePattern and Password. The first matching rule is used. |
| FilePattern | Text | Yes | Regex pattern matched against the input file name. Matching is case-insensitive. |
| Password | Text | Yes | Password used as the PDF document-open password for matching files. |
Conditional Field Rendering Rules
No conditional configuration fields are defined for this activity.
Sample Configuration
| FilePattern | Password |
|---|---|
^invoice-.*\.pdf$ | Invoice@2026 |
^statement-.*\.pdf$ | Statement@2026 |
Sample Output
{ "Files": [ { "FileName": "invoice-001.pdf", "FullPath": "C:/Workflow/invoice-001.pdf", "Size": 50124 }, { "FileName": "terms.pdf", "FullPath": "C:/Work/terms.pdf", "Size": 11020 } ], "Errors": [ "Already protected: statement-jan.pdf" ]}