Crop PDF

Crop PDF pages to specific dimensions with precise control over crop areas.

POSThttps://api.morphopdf.com/v1/pdf/crop

Authentication

AuthorizationBearer

Retrieve your API Key from Dashboard.

Request Body

One input source is required (file, fileBase64, or url).

fileFile

The PDF file to crop, uploaded via multipart/form-data.

fileBase64string

Base64-encoded PDF content as an alternative to file upload.

urlstring

Public URL of PDF file to fetch and crop.

Crop Options

cropDataarray

Array of crop definitions, each containing pageNumber and cropArea.

cropModestringOptional

Set 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:

pageNumbernumber

1-based page number to crop.

cropArea.xnumber

X coordinate of the crop area origin (from bottom-left).

cropArea.ynumber

Y coordinate of the crop area origin (from bottom-left).

cropArea.widthnumber

Width of the crop area.

cropArea.heightnumber

Height of the crop area.

cropArea.unitstringOptionalDefault: pt

Unit 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: json

Response 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):

successboolean

Indicates whether the operation completed successfully.

messagestring

Human-readable status message.

fileNamestring

Name of the cropped PDF file.

downloadUrlstring

Presigned URL to download the file. Valid for 1 hour.

pagesCroppednumber

Number of pages that were cropped.

Error Responses

StatusCodeDescription
400INVALID_INPUTInvalid crop dimensions or missing file
400CORRUPTED_FILEInvalid or corrupted PDF file
413FILE_TOO_LARGEFile exceeds maximum size (50MB)
500PROCESSING_FAILEDCrop operation failed
POST/v1/pdf/crop
curl -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
200OK
{
  "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
}