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

# CLI Commands

> Full reference for every CLI command.

## pdfbase create

Generate a PDF from HTML, a file, or a URL.

```bash theme={null}
pdfbase create [options]
```

| Option                  | Description                                     |
| ----------------------- | ----------------------------------------------- |
| `--html <string>`       | HTML string to render                           |
| `--from <type>`         | Source type: `html`, `url`                      |
| `--input <path-or-url>` | File path or URL (used with `--from`)           |
| `-o, --output <path>`   | Output file path (default: stdout)              |
| `--format <size>`       | Page format: a4, letter, legal, etc.            |
| `--margin <value>`      | Margins: `"20mm"` or `"top,right,bottom,left"`  |
| `--landscape`           | Landscape orientation                           |
| `--compress <level>`    | Compression: none, low, medium, high            |
| `--wait-until <event>`  | Load event: domcontentloaded, load, networkidle |
| `--wait-for <selector>` | CSS selector to wait for                        |
| `--timeout <ms>`        | Render timeout in milliseconds                  |
| `--debug`               | Include debug output                            |
| `--header <html>`       | Header HTML                                     |
| `--footer <html>`       | Footer HTML                                     |

### Examples

```bash theme={null}
# Minimal
pdfbase create --html "<h1>Hello</h1>" -o hello.pdf

# From file with options
pdfbase create --from html --input report.html -o report.pdf \
  --format letter --margin "25mm" --compress medium

# From URL with wait
pdfbase create --from url --input "https://app.com/report" \
  --wait-for "#ready" --timeout 60000 -o report.pdf

# Debug mode — saves debug info alongside PDF
pdfbase create --html "..." --debug -o output.pdf
# Creates: output.pdf, output.debug.json, output.screenshot.png
```

***

## pdfbase render

Render a stored template with data.

```bash theme={null}
pdfbase render <template-name> [options]
```

| Option                | Description                             |
| --------------------- | --------------------------------------- |
| `--data <json>`       | JSON string of template data            |
| `--data-file <path>`  | Path to a JSON file with template data  |
| `-o, --output <path>` | Output file path                        |
| `--format <size>`     | Override template's default format      |
| `--compress <level>`  | Override template's default compression |

### Examples

```bash theme={null}
# Inline data
pdfbase render invoice --data '{"number":"INV-001","customer":"Acme","total":"$500"}' -o inv.pdf

# From file
pdfbase render invoice --data-file ./invoices/acme.json -o inv.pdf
```

***

## pdfbase templates

Manage templates via templates-as-code.

### pdfbase templates push

Push local templates to PDFBase. Reads from `pdfbase.json`.

```bash theme={null}
pdfbase templates push [--dry-run]
```

`--dry-run` shows what would change without making changes.

### pdfbase templates pull

Pull remote templates to local files.

```bash theme={null}
pdfbase templates pull [--all | --name <name>]
```

### pdfbase templates preview

Render a template locally and open in your browser.

```bash theme={null}
pdfbase templates preview <name> [--data-file <path>] [--data <json>]
```

### pdfbase templates diff

Show differences between local and remote templates.

```bash theme={null}
pdfbase templates diff [--name <name>]
```

### pdfbase templates list

List all remote templates.

```bash theme={null}
pdfbase templates list [--json]
```

***

## pdfbase webhooks

Test and manage webhook endpoints.

### pdfbase webhooks test

Send a test event to a webhook endpoint.

```bash theme={null}
pdfbase webhooks test <endpoint-id> --event <event-type>
```

### pdfbase webhooks list

List all webhook endpoints.

```bash theme={null}
pdfbase webhooks list [--json]
```

***

## pdfbase merge

Merge multiple PDFs into one. (Phase 2)

```bash theme={null}
pdfbase merge <file1> <file2> [file3...] -o merged.pdf
```

| Option                | Description                                                             |
| --------------------- | ----------------------------------------------------------------------- |
| `-o, --output <path>` | Output file path                                                        |
| `--compress <level>`  | Compression level for output                                            |
| `--pages <ranges>`    | Per-file page ranges, comma-separated: `"1-3,,4-6"` (empty = all pages) |

***

## pdfbase split

Split a PDF into separate files. (Phase 2)

```bash theme={null}
pdfbase split <file> --ranges "1-5" "6-10" -o output-dir/
```

| Option                 | Description                               |
| ---------------------- | ----------------------------------------- |
| `--ranges <ranges...>` | Page ranges, each becomes a separate file |
| `-o, --output <path>`  | Output directory                          |

***

## pdfbase watermark

Add a watermark to a PDF. (Phase 2)

```bash theme={null}
pdfbase watermark <file> --text "DRAFT" -o watermarked.pdf
```

| Option                 | Description                                            |
| ---------------------- | ------------------------------------------------------ |
| `--text <string>`      | Watermark text                                         |
| `--color <hex>`        | Color with alpha (default: "#00000020")                |
| `--rotation <degrees>` | Rotation (default: -45)                                |
| `--position <pos>`     | center, top-left, top-right, bottom-left, bottom-right |
| `-o, --output <path>`  | Output file path                                       |

***

## pdfbase extract

Extract content from a PDF. (Phase 3)

```bash theme={null}
pdfbase extract text <file> [--format text|markdown|structured]
pdfbase extract ocr <file> [--language eng]
pdfbase extract tables <file> [--format json|csv]
pdfbase extract structured <file> --preset invoice
```

| Option              | Description                                              |
| ------------------- | -------------------------------------------------------- |
| `--format <fmt>`    | Output format                                            |
| `--language <lang>` | OCR language code                                        |
| `--preset <name>`   | AI extraction preset: invoice, receipt, contract, resume |
| `--schema <json>`   | Custom extraction schema (JSON string)                   |
| `--pages <range>`   | Pages to extract from                                    |

***

## pdfbase convert

Convert between formats. (Phase 2)

```bash theme={null}
pdfbase convert office <file> -o output.pdf
pdfbase convert thumbnail <file> [--page 1] -o thumb.png
```

| Option                | Description                            |
| --------------------- | -------------------------------------- |
| `--page <num>`        | Page number for thumbnail (default: 1) |
| `--landscape`         | Force landscape for office conversion  |
| `-o, --output <path>` | Output file path                       |

***

## pdfbase batch

Create and manage batch jobs. (Phase 1)

```bash theme={null}
# Create a batch from a JSON file
pdfbase batch create --items batch-items.json

# Check batch status
pdfbase batch status <batch-id>

# Download all results
pdfbase batch download <batch-id> -o output-dir/
```

| Option                | Description                      |
| --------------------- | -------------------------------- |
| `--items <path>`      | JSON file with batch items array |
| `--parallel <n>`      | Concurrent renders (default: 5)  |
| `--output <mode>`     | individual, merged, or zip       |
| `-o, --output <path>` | Output path for downloads        |

***

## pdfbase requests

Manage and replay API requests.

```bash theme={null}
# List recent requests
pdfbase requests list [--limit 10] [--status completed|failed]

# Replay a request with debug enabled
pdfbase requests replay <request-id>
```

***

## pdfbase auth

Manage authentication.

```bash theme={null}
pdfbase auth login     # Interactive login
pdfbase auth logout    # Remove stored credentials
pdfbase auth status    # Show current auth state
```

***

## pdfbase status

Check PDFBase API status and your account usage.

```bash theme={null}
pdfbase status
```

Output:

```
API: ✓ healthy (23ms)
Account: your-email@example.com
Plan: Pro ($99/mo)
Usage: 1,247 / 10,000 credits this month
Rate limit: 300 req/min (using 0)
```
