Crop PDF
Crop PDF pages to specific dimensions with precise control over crop areas.
https://api.morphopdf.com/v1/pdf/cropAuthentication
Retrieve your API Key from Dashboard.
Request Body
One input source is required (file, fileBase64, or url).
fileFileThe PDF file to crop, uploaded via multipart/form-data.
fileBase64stringBase64-encoded PDF content as an alternative to file upload.
urlstringPublic URL of PDF file to fetch and crop.
Crop Options
cropDataarrayArray of crop definitions, each containing pageNumber and cropArea.
cropModestringOptionalSet to 'all' to apply the first crop area to all pages, or omit for per-page cropping.
Crop Area Object
Each item in cropData must include:
pageNumbernumber1-based page number to crop.
cropArea.xnumberX coordinate of the crop area origin (from bottom-left).
cropArea.ynumberY coordinate of the crop area origin (from bottom-left).
cropArea.widthnumberWidth of the crop area.
cropArea.heightnumberHeight of the crop area.
cropArea.unitstringOptionalDefault: ptUnit for dimensions: 'px' (pixels), 'pt' (points), 'mm' (millimeters), or 'in' (inches).
Coordinate System
- Origin: Coordinates start from the bottom-left corner of the page
- Units: Default is points (pt). 72 points = 1 inch
- Get dimensions: Use GET /v1/pdf/crop?filePath=... to retrieve page dimensions before cropping
Query Parameters
formatstringOptionalDefault: jsonResponse format. Use 'binary' to receive the cropped 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 cropped PDF file.
downloadUrlstringPresigned URL to download the file. Valid for 1 hour.
pagesCroppednumberNumber of pages that were cropped.
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_INPUT | Invalid crop dimensions or missing file |
| 400 | CORRUPTED_FILE | Invalid or corrupted PDF file |
| 413 | FILE_TOO_LARGE | File exceeds maximum size (50MB) |
| 500 | PROCESSING_FAILED | Crop operation failed |
/v1/pdf/cropcurl -X POST "https://api.morphopdf.com/v1/pdf/crop?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf" \
-F 'cropData=[{"pageNumber": 1, "cropArea": {"x": 50, "y": 50, "width": 400, "height": 600, "unit": "pt"}}]' \
--output cropped.pdf{
"success": true,
"message": "File processed successfully",
"fileName": "cropped.pdf",
"downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/cropped.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
"pagesCropped": 3
}