Encrypt / re-secure a PDF
encrypt_pdfEncrypt a PDF with AES-128 or AES-256, set owner and user passwords, and control print/copy/modify/extract-text permissions. Can also rotate the password of an already-encrypted PDF.
Instructions
Encrypt an existing PDF with the Standard Security Handler: AES-128 (default) or AES-256; RC4 is never emitted. ownerPassword required; optional userPassword (open password), permissions { print, copy, modify, extractText }. Rotate the password of an already-encrypted source by passing its current password. CAVEAT: the page tree is rebuilt — signatures and AcroForm are DROPPED, only URI links kept; encrypt BEFORE signing. Never cached.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| password | No | Current password of an already-encrypted source (enables password rotation). Omit for an unencrypted source. | |
| algorithm | No | aes128 (V4/R4, widest compatibility) or aes256 (V5/R6). | aes128 |
| pdfBase64 | Yes | Base64-encoded source PDF to encrypt. NOTE: existing signatures and AcroForm are dropped (page-tree rebuild). | |
| outputMode | No | 'base64' (default) returns the PDF inline; 'file' writes it inside the PDFNATIVE_MCP_OUTPUT_DIR sandbox (SECURITY_VIOLATION when the sandbox is not configured). | base64 |
| outputPath | No | Required when outputMode='file'. Relative path inside the sandbox; must end with .pdf. | |
| permissions | No | Permission flags; each defaults to allowed. | |
| userPassword | No | Open password; omitted/empty = opens without a prompt. | |
| ownerPassword | Yes | Owner password (full access). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | ||
| summary | No | Tool-specific summary, when produced. | |
| filePath | No | Sandboxed absolute path (file mode). | |
| sizeBytes | Yes | ||
| diagnostics | No | PDF/A diagnostics (when includeDiagnostics=true). |