Watermark PDF
Add text or image watermarks to PDF documents with customizable positioning and styling.
https://api.morphopdf.com/v1/pdf/watermarkAuthentication
Retrieve your API Key from Dashboard.
Request Body
One input source is required (file, fileBase64, or url).
fileFileThe PDF file to watermark, uploaded via multipart/form-data.
fileBase64stringBase64-encoded PDF content as an alternative to file upload.
urlstringPublic URL of PDF file to fetch and watermark.
Watermark Configuration
watermarkTypestringType of watermark: 'text' or 'image'.
watermarkOptionsobjectConfiguration object for the watermark (see options below).
pagesstring | number[]OptionalDefault: allPages to watermark: 'all' or array of 1-based page numbers [1, 3, 5].
Text Watermark Options
When watermarkType is 'text':
textstringThe watermark text to display.
fontSizenumberOptionalDefault: 48Font size in points.
colorstringOptionalDefault: #000000Hex color code for the text.
opacitynumberOptionalDefault: 0.3Transparency level from 0 (invisible) to 1 (solid).
positionstringOptionalDefault: centerPlacement: 'top-left', 'top-center', 'top-right', 'middle-left', 'center', 'middle-right', 'bottom-left', 'bottom-center', 'bottom-right', or 'custom'.
rotationnumberOptionalDefault: -45Rotation angle in degrees. Use -45 for diagonal watermarks.
customXnumberOptionalX position as percentage (0-100) when position='custom'.
customYnumberOptionalY position as percentage (0-100) when position='custom'.
Image Watermark Options
When watermarkType is 'image':
imageDatastringOptionalBase64-encoded PNG or JPEG image data.
imageUrlstringOptionalPublic URL of the watermark image to fetch.
widthnumberOptionalWidth of the watermark image in points.
heightnumberOptionalHeight of the watermark image in points.
opacitynumberOptionalDefault: 0.3Transparency level from 0 (invisible) to 1 (solid).
positionstringOptionalDefault: centerSame position options as text watermarks.
rotationnumberOptionalDefault: 0Rotation angle in degrees.
Common Watermark Patterns
- Diagonal text: Use rotation: -45 with position: center
- Logo in corner: Use image type with position: bottom-right
- Subtle branding: Use low opacity (0.1-0.3)
Image URL Requirements
When using imageUrl, the image must be publicly accessible. The API will fetch the image with a 15-second timeout and 10MB size limit.
Query Parameters
formatstringOptionalDefault: jsonResponse format. Use 'binary' to receive the watermarked PDF file directly, or 'json' (default) to receive metadata with a download URL.
Response
When using format=json (default):
successbooleanIndicates whether the operation completed successfully.
messagestringHuman-readable status message.
fileNamestringName of the watermarked PDF file.
downloadUrlstringPresigned URL to download the file. Valid for 1 hour.
pagesWatermarkednumberNumber of pages that received the watermark.
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_INPUT | Missing required fields or invalid watermark type |
| 400 | URL_FETCH_FAILED | Failed to fetch watermark image from URL |
| 413 | FILE_TOO_LARGE | File exceeds maximum size (50MB) |
| 500 | PROCESSING_FAILED | Watermark operation failed |
/v1/pdf/watermarkcurl -X POST "https://api.morphopdf.com/v1/pdf/watermark?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "watermarkType=text" \
-F 'watermarkOptions={"text": "CONFIDENTIAL", "fontSize": 48, "color": "#FF0000", "opacity": 0.3, "position": "center", "rotation": -45}' \
--output watermarked.pdf{
"success": true,
"message": "File processed successfully",
"fileName": "watermarked.pdf",
"downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/watermarked.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
"pagesWatermarked": 10
}