---
title: Decrypt PDF (remove password)
description: Remove password protection from encrypted PDF files using filename-based password rules.
category: File Transformations
tags: [pdf, decrypt, password, files]
---

# Decrypt PDF (remove password)

## **Description**

The **Decrypt PDF (remove password)** activity processes input PDF files and removes password protection when a configured password rule matches the file name. It preserves files that are already unprotected, reports errors for corrupt PDFs, and reports password errors when the configured password is incorrect.

### **Supported Features**

- **Multiple file processing**: Processes each input file independently.
- **Regex-based password rules**: Match files using `FilePattern` and apply the corresponding password.
- **Encrypted PDF detection**: Detects whether a PDF is encrypted before attempting decryption.
- **Unprotected PDF passthrough**: Unencrypted PDFs are skipped and returned unchanged.
- **Error collection**: Collects errors for invalid PDFs, missing rules, incorrect passwords, and processing failures.

---

## **Input**

| Type | Required | Description |
| --- | --- | --- |
| Files | Yes | PDF files to decrypt. |

### **Input Scenarios**

#### **1. Encrypted PDF With Matching Rule**

```json
{
  "Files": [
    { "FileName": "bank-statement-jan.pdf", "FullPath": "C:/Work/bank-statement-jan.pdf" }
  ]
}
```

#### **2. Unencrypted PDF**

The file is returned unchanged and an informational message is logged.

```json
{
  "Files": [
    { "FileName": "public-report.pdf", "FullPath": "C:/Work/public-report.pdf" }
  ]
}
```

#### **3. Encrypted PDF With No Matching Rule**

The activity records an error: `No password rule matched for: <file>`.

---

## **Output**

| Field | Type | Description |
| --- | --- | --- |
| Files | Array | Decrypted PDF files or unchanged input files for PDFs that were not password protected. |
| Errors | Array | Errors for files that could not be decrypted or validated. |

### **Output Behavior**

- If at least one file succeeds and some files fail, the activity returns success with errors.
- If all files fail, the activity returns failure.
- Decrypted files are written to the workflow base working folder using the original file name.

### **Example Output**

```json
{
  "Files": [
    {
      "FileName": "bank-statement-jan.pdf",
      "FullPath": "C:/Workflow/bank-statement-jan.pdf",
      "Size": 45821
    }
  ],
  "Errors": []
}
```

---

## **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 to open and decrypt files that match `FilePattern`. |

### **Conditional Field Rendering Rules**

No conditional configuration fields are defined for this activity.

---

## **Sample Configuration**

| FilePattern | Password |
| --- | --- |
| `^bank-statement-.*\.pdf$` | `Bank@2026` |
| `^invoice-.*\.pdf$` | `Invoice@2026` |

---

## **Sample Output**

```json
{
  "Files": [
    {
      "FileName": "bank-statement-jan.pdf",
      "FullPath": "C:/Workflow/bank-statement-jan.pdf",
      "Size": 45821
    }
  ],
  "Errors": [
    "Incorrect password for: invoice-001.pdf"
  ]
}
```
