Security Endpoints
Protect, compress, repair, redact, and linearize PDF documents via the REST API.
Overview
The security endpoints provide tools to protect PDFs with passwords and permissions, compress files to reduce size, repair damaged documents, permanently redact sensitive content, and linearize PDFs for fast web viewing. All endpoints return the processed PDF in the response body.
X-Api-Key and X-Api-Secret headers on every request. See Authentication for details.
Protect PDF
POST /api/pdf/protect
Adds password protection and permission restrictions to a PDF document. You can set an open password (required to view the document) and a permissions password (required to change security settings).
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The PDF file to protect. |
openPassword | String | No | Password required to open and view the document. If omitted, no open password is set. |
permissionsPassword | String | No | Password required to change permissions and security settings. At least one password must be provided. |
allowPrinting | Boolean | No | Allow printing the document. Default: true. |
allowCopying | Boolean | No | Allow copying text and images from the document. Default: true. |
allowEditing | Boolean | No | Allow modifying the document content. Default: false. |
allowAnnotations | Boolean | No | Allow adding annotations and form filling. Default: true. |
encryption | String | No | Encryption level: aes128 (default), aes256, rc4-128. |
currentPassword | String | No | Current password if the PDF is already protected. |
outputFileName | String | No | Custom name for the output PDF file. |
curl -X POST https://pdf.mapsoft.com/api/pdf/protect \
-H "X-Api-Key: YOUR_API_KEY" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-F "file=@document.pdf" \
-F "openPassword=ViewerPass123" \
-F "permissionsPassword=OwnerPass456" \
-F "allowPrinting=true" \
-F "allowCopying=false" \
-F "allowEditing=false" \
-F "encryption=aes256" \
-o protected.pdf
Compress PDF
POST /api/pdf/compress
Reduces the file size of a PDF document by compressing images, removing unused objects, and optimizing the internal structure.
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The PDF file to compress. |
quality | String | No | Compression quality: low (smallest file), medium (default, balanced), high (best quality, larger file). |
imageResolution | Integer | No | Target DPI for embedded images. Default: 150. Range: 72–300. |
removeMetadata | Boolean | No | Strip metadata to reduce file size. Default: false. |
outputFileName | String | No | Custom name for the output PDF file. |
password | String | No | Password to open the PDF, if it is password-protected. |
curl -X POST https://pdf.mapsoft.com/api/pdf/compress \
-H "X-Api-Key: YOUR_API_KEY" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-F "file=@large-document.pdf" \
-F "quality=medium" \
-F "imageResolution=150" \
-o compressed.pdf
Repair PDF
POST /api/pdf/repair
Attempts to repair a damaged or corrupted PDF document by rebuilding the cross-reference table, fixing broken object references, and recovering readable content.
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The damaged PDF file to repair. |
outputFileName | String | No | Custom name for the repaired PDF file. |
password | String | No | Password to open the PDF, if it is password-protected. |
curl -X POST https://pdf.mapsoft.com/api/pdf/repair \
-H "X-Api-Key: YOUR_API_KEY" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-F "file=@damaged.pdf" \
-o repaired.pdf
Redact PDF
POST /api/pdf/redact
Permanently removes sensitive content from a PDF document by applying redaction annotations. Redacted content is irreversibly replaced with black rectangles and cannot be recovered.
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The PDF file to redact. |
searchText | String | No | Text to search for and redact. All occurrences will be redacted. |
searchRegex | String | No | Regular expression pattern to match text for redaction (e.g., \b\d{3}-\d{2}-\d{4}\b for SSNs). |
pages | String | No | Pages to redact (e.g., 1-5). Defaults to all pages. |
redactColor | String | No | Color of redaction boxes as hex code. Default: #000000 (black). |
outputFileName | String | No | Custom name for the output PDF file. |
password | String | No | Password to open the PDF, if it is password-protected. |
curl -X POST https://pdf.mapsoft.com/api/pdf/redact \
-H "X-Api-Key: YOUR_API_KEY" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-F "file=@sensitive-document.pdf" \
-F "searchRegex=\b\d{3}-\d{2}-\d{4}\b" \
-F "redactColor=#000000" \
-o redacted.pdf
Linearize PDF
POST /api/pdf/linearize
Linearizes a PDF document for "fast web view." Linearized PDFs are optimized so that the first page can be displayed immediately while the rest of the document continues loading in the background. This is especially useful for large documents served over the web.
| Name | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The PDF file to linearize. |
outputFileName | String | No | Custom name for the output PDF file. |
password | String | No | Password to open the PDF, if it is password-protected. |
curl -X POST https://pdf.mapsoft.com/api/pdf/linearize \
-H "X-Api-Key: YOUR_API_KEY" \
-H "X-Api-Secret: YOUR_API_SECRET" \
-F "file=@document.pdf" \
-o linearized.pdf