Pages
Crop PDF
Trim a PDF — auto-detect and shave whitespace around the content, inset by fixed margins, or crop to an explicit box. The cropped PDF is streamed straight back.
Login required 10 credits / callSynchronous
Overview
Measurements are in PDF points (72 pt = 1 inch). Page numbers are 1-based.
POST
https://api.bytefuse.in/api/v1/pdf/cropCrop requires authentication
Unlike the other page tools, Crop is not free-to-try — an anonymous call returns401. Send a dt_live_ key or JWT.Request
Content type multipart/form-data:
filefilerequiredThe PDF to crop.
modestringoptionalauto, margins or box. Any other value returns 400.Default: autopaddingfloatoptionalauto mode only. Whitespace (points) kept around detected content, 0–200. Ignored in other modes.Default:
6.0marginsstringoptionalmargins mode only.
"top,right,bottom,left" in points (exactly four numbers).boxstringoptionalbox mode only.
"x0,y0,x1,y1" in points from each page’s top-left (exactly four numbers).pagesstringoptional1-based page list, e.g.
"1,3". Omit to crop every page.Default: all pagesModes
- auto — per page, shrink the crop box to the inked content plus
padding. Blank pages are left untouched. - margins — inset every page by
[top, right, bottom, left]. - box — set an explicit crop rectangle from the page top-left.
Mode-scoped parameters
padding applies only in auto, margins only in margins, box only in box. Off-mode parameters are accepted and ignored. A crop that would shrink a page below 1 pt is skipped, leaving that page unchanged.Response
The file is returned directly
Unlike the URL-returning tools, page operations stream the edited PDF back as the response body —application/pdf with Content-Disposition: attachment. Read the raw bytes and save them; there is no JSON envelope. The X-Credits-Charged header reports the credits billed (0 for anonymous calls).Examples
# auto-trim whitespace on all pages
curl -X POST https://api.bytefuse.in/api/v1/pdf/crop \
-H "X-API-Key: dt_live_your_key" \
-F "file=@scan.pdf" \
-F "mode=auto" \
-F "padding=6" \
-o cropped.pdfErrors
401Anonymous / not signed in — Crop is login-only.
400Invalid
mode, padding out of range, a margins/box that isn’t exactly four numbers, a bad pages list, or a corrupt PDF.402 / 429 / 503Insufficient credits, rate limited, or capacity/config error.
500The crop failed unexpectedly.
