PDF & images
to-image, thumbnail, from-images.
Three operations bridge PDFs and images: rasterize pages to PNG, get a quick page-1 thumbnail, and build a PDF from images.
PDF=$(base64 -w0 input.pdf) # macOS: base64 -i input.pdfPDF to images
POST /v1/pdf/to-image renders pages to PNG. Returns JSON:
curl -X POST https://api.pdf-forge.dev/v1/pdf/to-image \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\", \"dpi\": 150, \"pages\": [\"1\", \"2\"]}"{
"pages": [
{ "page": 1, "width": 1240, "height": 1754,
"image": "<base64 PNG>", "format": "png" }
],
"page_count": 2
}const result = await client.pdf.toImage(pdfBytes, {
dpi: 150,
pages: ["1", "2"],
});
// result.pages[0].png: Uint8Array — ready to write to disk| Field | Type | Description |
|---|---|---|
pdf | string | Required. Base64 PDF. |
dpi | number | Render resolution. Higher = sharper and heavier. |
pages | string[] | Page selection (["1", "3-5"]). Default: all pages. |
Thumbnail
POST /v1/pdf/thumbnail renders page 1 only and returns the PNG binary
directly (default 72 dpi — small on purpose):
curl -X POST https://api.pdf-forge.dev/v1/pdf/thumbnail \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"pdf\": \"$PDF\"}" \
--output thumbnail.pngOptional dpi overrides the resolution. Ideal for file pickers and document
lists.
Images to PDF
POST /v1/pdf/from-images builds a PDF with one page per image (PNG/JPG),
in order:
curl -X POST https://api.pdf-forge.dev/v1/pdf/from-images \
-H "Authorization: Bearer $PDFFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"images\": [\"$(base64 -w0 scan1.jpg)\", \"$(base64 -w0 scan2.jpg)\"]}" \
--output scans.pdfconst pdf = await client.pdf.fromImages([scan1Bytes, scan2Bytes]);to-image + from-images = flatten
Chaining the two rasterizes a PDF: every page becomes pixels. That is how you make a redaction irreversible on scanned documents — nothing survives under the black boxes.
There is also POST /v1/pdf/from-url, an alias of
URL to PDF.
Next steps
- True redaction — the flatten use case.
- Inspect — check effective image DPI in a PDF.
- Assemble & split — merge the scanned PDF with others.