Rotate PDF
Rotate PDF pages by specified angles with flexible per-page or global rotation options.
https://api.morphopdf.com/v1/pdf/rotateAuthentication
Retrieve your API Key from Dashboard.
Request Body
One input source is required (file, fileBase64, or url).
fileFileThe PDF file to rotate, uploaded via multipart/form-data.
fileBase64stringBase64-encoded PDF content as an alternative to file upload.
urlstringPublic URL of PDF file to fetch and rotate.
Rotation Options (Strategy 1)
Use rotations map for different angles per page:
rotationsobjectOptionalMap of page numbers to rotation angles. Example: {'1': 90, '3': 180, '5': 270}
Rotation Options (Strategy 2)
Use angle with optional pages for uniform rotation:
anglenumberOptionalRotation angle in degrees (e.g., 90, 180, 270). Can be any value.
pagesnumber[]OptionalArray of 1-based page numbers to rotate. If omitted, rotates all pages.
Rotation Behavior
- Cumulative: Rotation is added to existing page rotation (90 + 90 = 180)
- Normalization: Angles are normalized to 0-360 range automatically
- Strategy priority: If both rotations and angle are provided, rotations takes precedence
Encrypted PDFs
Password-protected PDFs cannot be rotated. Use the Unlock PDF endpoint first to remove protection.
Query Parameters
formatstringOptionalDefault: jsonResponse format. Use 'binary' to receive the rotated 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 rotated PDF file.
downloadUrlstringPresigned URL to download the file. Valid for 1 hour.
pagesRotatednumberNumber of pages that were rotated.
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_INPUT | Missing file or invalid parameters |
| 400 | PASSWORD_PROTECTED | Cannot rotate password-protected PDF |
| 413 | FILE_TOO_LARGE | File exceeds maximum size (50MB) |
| 500 | PROCESSING_FAILED | Rotation operation failed |
/v1/pdf/rotatecurl -X POST "https://api.morphopdf.com/v1/pdf/rotate?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F "angle=90" \
-F "pages=[1,3,5]" \
--output rotated.pdf{
"success": true,
"message": "File processed successfully",
"fileName": "rotated.pdf",
"downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/rotated.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
"pagesRotated": 3
}