> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dockiln.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Render PDFs and images

> Choose a source, output format and page settings for a document job.

## Select one source

`POST /v1/documents` accepts exactly one of `html`, `url` or `templateId`. Structured templates use Typst for PDFs. Chromium prints HTML and URL snapshots and produces PNG, JPEG and WebP images.

HTML input is limited to 512 KiB. For a public URL, the fetcher validates the destination and each redirect before passing HTML to the isolated renderer. Use inline CSS and embedded data images. Remote stylesheets, web fonts, frames and scripts are blocked. A client-rendered page that needs JavaScript should be turned into self-contained HTML on your server first.

## Set paper and margins

```json title="PDF request body" theme={null}
{
  "html": "<h1>Inspection report</h1><p style='break-before:page'>Appendix</p>",
  "page": {
    "format": "A4", "landscape": false, "margin": 16,
    "header": "Field operations", "footer": "Page {page} of {pages}"
  },
  "compress": true
}
```

Paper sizes are `A4`, `Letter`, `Legal` and `Label` (A6). Margins are whole millimetres from 8 to 35. Chromium headers and footers accept the page-number placeholders above. Structured templates interpolate JSON fields and add their own page counter. Lossless compression keeps the smaller of the original PDF and the rewritten file.

## Capture a social image

```json title="WebP request body" theme={null}
{
  "format": "webp",
  "html": "<main class='card'><h1>Field notes</h1></main>",
  "controls": {
    "preset": "og",
    "media": "screen",
    "selector": ".card",
    "timeoutMs": 2000,
    "css": "body { background: #173b31; color: white; padding: 48px }"
  }
}
```

Use `og` for 1200 × 630, `square` for 1080 × 1080 or `story` for 1080 × 1920. Use `width` and `height` to override the viewport. A published Social card template can supply the source in place of HTML.

## Control readiness

| Control | Accepted values or behaviour |
| - | - |
| `media` | `print` (default) or `screen` |
| `width`, `height` | Integers, 160–2400 px wide and 100–2400 px high |
| `fullPage` | Captures the full scroll area for an image, subject to size and pixel limits |
| `waitFonts`, `waitImages` | Enabled by default for available embedded resources |
| `selector`, `timeoutMs` | Wait for a matching element with a timeout of 100–5000 ms |
| `css` | Additional CSS applied inside the isolated browser |

Invalid options return **422** before admission. A missing selector can instead produce a failed job after admission. Read the job's `error` field. All output formats share a 16 MiB render limit.

## Review build rendering controls

The 1.1 review build adds custom print dimensions, ranges, styled page bands, PDF protection, image crops and bounded opt-in dynamic rendering. [Read the migration guide](https://docs.dockiln.io/pdfshift-migration.md).

For worked PDF examples, see [headers and footers](https://docs.dockiln.io/misc/header-footer.md), [margins](https://docs.dockiln.io/misc/margins.md), [password protection](https://docs.dockiln.io/misc/protection.md) and [watermarks](https://docs.dockiln.io/misc/watermark.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.