# PDF

> Convert web pages or your own HTML to PDF with paper sizes, margins, backgrounds and one-page fitting.

## URL to PDF

Set `format=pdf`:

```bash
curl -X POST "https://shotkit.net/api/take" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","format":"pdf"}' \
  --fail-with-body -o shot.pdf
```

The page is printed the way Chrome prints it: text stays selectable and links stay clickable. Sites with print stylesheets use them. To get a PDF that looks like the screen instead, print backgrounds and use the screen media type:

```bash
curl -X POST "https://shotkit.net/api/take" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","format":"pdf","pdf_print_background":true,"media_type":"screen"}' \
  --fail-with-body -o shot.pdf
```

## Paper and margins

| Option | Default | Values |
| --- | --- | --- |
| `pdf_paper_format` | `letter` | `a0`–`a6`, `letter`, `legal`, `tabloid` |
| `pdf_landscape` | `false` | |
| `pdf_margin` | `0` | Any CSS length: `20px`, `1cm`, `0.5in` |
| `pdf_margin_top`, `_right`, `_bottom`, `_left` | `pdf_margin` | Override one side. |

```bash
curl -X POST "https://shotkit.net/api/take" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","format":"pdf","pdf_paper_format":"a4","pdf_margin":"1.5cm","pdf_margin_top":"2.5cm"}' \
  --fail-with-body -o shot.pdf
```

## One long page

`pdf_fit_one_page=true` puts the whole page on a single PDF page sized to the content, with no page breaks. Good for archiving and sharing a page as it looks on screen:

```bash
curl -X POST "https://shotkit.net/api/take" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","format":"pdf","pdf_fit_one_page":true,"pdf_print_background":true}' \
  --fail-with-body -o shot.pdf
```

## HTML to PDF

For invoices, receipts and reports, render your own template. Use CSS for page layout: `@page` rules, `break-before: page` and `break-inside: avoid` all work.

```bash
curl -X POST "https://shotkit.net/api/take" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<style>body{font:14px system-ui} table{width:100%} .total{break-inside:avoid}</style><h1>Invoice #1042</h1><table><tr><td>Pro plan</td><td>$90.00</td></tr></table><p class=\"total\">Total: $90.00</p>","format":"pdf","pdf_paper_format":"a4","pdf_margin":"2cm"}' \
  --fail-with-body -o shot.pdf
```

Everything that changes the page also works for PDFs: [blocking](https://shotkit.net/docs/clean-screenshots.md), `styles`, `scripts`, `hide_selectors`, cookies and waits.
