smallapis

PDF Toolkit API

The PDF operations every back office needs, without shipping Ghostscript and qpdf into your own image. Returns the binary directly, or JSON when you ask for metadata.

10 endpoints

Click one to see its parameters and a ready-to-paste curl call.

POST /v1/pdf/merge Merge several PDFs into one

Repeat the `file` part, or pass `urls` as a comma-separated list. Up to 20 documents per call.

Returns: binary pdf

ParameterTypeDescription
file file A PDF. Repeat the part for each document.
urls string Comma-separated public URLs instead of uploads.
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/merge" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  --output result.bin
POST /v1/pdf/split Extract a page selection into a new PDF

Extract a page selection into a new PDF

Returns: binary pdf

ParameterTypeDescription
file file Source PDF.
pages required string Selection such as "1,3,5-9". Order is preserved.
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/split" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "pages=1,3,5-9" \
  --output result.bin
POST /v1/pdf/compress Reduce the size of a PDF

Runs Ghostscript and returns whichever of the two files is smaller, so a call can never inflate a document.

Returns: binary pdf

ParameterTypeDescription
file file Source PDF.
level string screen, ebook, printer or prepress, from smallest to sharpest. Default: ebook
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/compress" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "level=ebook" \
  --output result.bin
POST /v1/pdf/to-images Render PDF pages to PNG or JPEG

A single page comes back as a binary image; several pages come back as JSON with base64 payloads.

Returns: binary image or json

ParameterTypeDescription
file file Source PDF.
first integer First page to render, 1-based. Default: 1
last integer Last page to render. At most 50 pages per call.
dpi integer Render resolution, 36-400. Default: 150
format string png or jpeg. Default: png
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/to-images" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "first=1" \
  -F "dpi=150" \
  -F "format=png" \
  --output result.bin
POST /v1/pdf/from-images Build a PDF from images

Build a PDF from images

Returns: binary pdf

ParameterTypeDescription
file file An image. Repeat the part for each page.
margin integer White margin in points. Default: 0
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/from-images" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "margin=0" \
  --output result.bin
POST /v1/pdf/extract-text Pull the text layer out of a PDF

Also returns `scannedLikely`, which tells you when to fall back to the OCR API.

Returns: json

ParameterTypeDescription
file file Source PDF.
layout boolean Keep the visual column layout. Default: false
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/extract-text" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "layout=false"
POST /v1/pdf/info Read page count, size, author and encryption state

Read page count, size, author and encryption state

Returns: json

ParameterTypeDescription
file file Source PDF.
url string Public URL instead of an upload.
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/info" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf"
POST /v1/pdf/protect Encrypt a PDF with a password (AES-256)

Encrypt a PDF with a password (AES-256)

Returns: binary pdf

ParameterTypeDescription
file file Source PDF.
password required string User password, 4 characters or more.
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/protect" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "password=s3cret-pass" \
  --output result.bin
POST /v1/pdf/unlock Remove the password from a PDF you own

Remove the password from a PDF you own

Returns: binary pdf

ParameterTypeDescription
file file Encrypted PDF.
password string Current password.
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/unlock" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  --output result.bin
POST /v1/pdf/watermark Draw a diagonal text watermark on every page

Draw a diagonal text watermark on every page

Returns: binary pdf

ParameterTypeDescription
file file Source PDF.
text required string Caption to draw.
opacity number Fill opacity, 0.02-1. Default: 0.18
angle integer Rotation in degrees, -90 to 90. Default: 45
curl -X POST "https://173-249-18-142.sslip.io/v1/pdf/watermark" \
  -H "X-API-Key: $SMALLAPIS_KEY" \
  -F "file=@input.pdf" \
  -F "text=CONFIDENTIAL" \
  -F "opacity=0.18" \
  -F "angle=45" \
  --output result.bin