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

# PDF Generation

> Generate PDF documents from web pages

Generate PDF documents from any web page.

## Basic PDF

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST https://api.snapopa.com/capture \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://example.com",
        "format": "pdf"
      }'
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    const response = await fetch('https://api.snapopa.com/capture', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        url: 'https://example.com',
        format: 'pdf',
      }),
    });

    const data = await response.json();
    console.log(data.data.fileUrl);
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    response = requests.post(
        'https://api.snapopa.com/capture',
        headers={
            'Authorization': 'Bearer YOUR_API_KEY',
            'Content-Type': 'application/json',
        },
        json={
            'url': 'https://example.com',
            'format': 'pdf',
        }
    )

    data = response.json()
    print(data['data']['fileUrl'])
    ```
  </Tab>
</Tabs>

## Full Page PDF

Capture the entire scrollable page as PDF:

```json theme={null}
{
  "url": "https://example.com",
  "format": "pdf",
  "isFullPage": true
}
```

<Tip>
  PDFs with `isFullPage: true` will have continuous pages matching the full page height.
</Tip>

## Download PDF Directly

Get the raw PDF file instead of a JSON response:

```bash theme={null}
curl -X POST https://api.snapopa.com/capture \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "pdf",
    "responseType": "file"
  }' \
  -o document.pdf
```

## PDF Features

* **Vector text** - Text is selectable and searchable
* **Links preserved** - Clickable links work in the PDF
* **Print-ready** - Suitable for printing
* **Accurate rendering** - Matches browser display

## Use Cases

* **Invoices** - Generate printable invoices from web apps
* **Reports** - Convert dashboards to PDF reports
* **Documentation** - Export docs for offline reading
* **Archives** - Long-term document preservation

## Best Practices

For best PDF results:

```json theme={null}
{
  "url": "https://example.com",
  "format": "pdf",
  "isFullPage": true,
  "waitUntil": "networkidle",
  "timeout": 60000
}
```

1. **Use `isFullPage`** - Captures complete content
2. **Wait for content** - Use `networkidle` for dynamic pages
3. **Increase timeout** - Complex pages need more time
4. **Test print styles** - Check `@media print` CSS
