pdf.page_boxes
Read or set the media, crop, trim, bleed and art boxes of pages (points, origin at the top-left of the media box, y down); read answers JSON, set answers the PDF.
POST /v1/pdf/page-boxes
| Input | one file, sent as multipart/form-data; the optional options part is a JSON object |
| Output | bytes (content type stated per request) |
| Credits | [credit rate: no claim ID yet] |
| Limits | [size, page and time limits: no claim ID yet] |
| Reads or changes the document | returns a changed copy |
| Error statuses | 400, 413, 422, 500, 501, 504 (see Errors) |
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
action |
string | yes | read answers with JSON, set answers with the changed PDF. read: Answer with the boxes of the pages as JSON. set: Set the given boxes on the pages and return the PDF. |
|
boxes |
object | no | For set: the boxes, in the coordinates described above. |
|
pages |
array of integer | no | One-based pages. Default: every page. | |
password |
string | no | Password of an encrypted document. |
Example
Section titled “Example”curl -sS -f -X POST "$PDFLUENT_API_URL/v1/pdf/page-boxes" \ -H "x-api-key: $PDFLUENT_API_KEY" \ -F file=@structured.pdf \ -F 'options={"action":"read"}' \ -o result.binimport jsonimport os
import requests
options = {"action": "read"}
parts = [ ("file", ("structured.pdf", open("structured.pdf", "rb"))), ("options", (None, json.dumps(options))),]
response = requests.post( os.environ["PDFLUENT_API_URL"] + "/v1/pdf/page-boxes", headers={"x-api-key": os.environ["PDFLUENT_API_KEY"]}, files=parts,)response.raise_for_status()
with open("result.bin", "wb") as out: out.write(response.content)import { openAsBlob } from 'node:fs';import { writeFile } from 'node:fs/promises';
const form = new FormData();form.append('file', await openAsBlob("structured.pdf"), "structured.pdf");form.append('options', JSON.stringify({"action":"read"}));
const response = await fetch(process.env.PDFLUENT_API_URL + "/v1/pdf/page-boxes", { method: 'POST', headers: { 'x-api-key': process.env.PDFLUENT_API_KEY }, body: form,});if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
await writeFile("result.bin", Buffer.from(await response.arrayBuffer()));The key goes in the x-api-key header; see Authentication. Every response carries x-pdfluent-pages and x-pdfluent-credits.