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

# HTML to PDF

> Render an HTML document as a PDF with Cloudflare Browser Rendering.

**HTML to PDF** renders an HTML string in Cloudflare's remote browser and
returns the result as a PDF file. Use it for invoices, reports, certificates,
and other documents assembled earlier in a workflow.

## Inputs

| Input                         | Type               | Required | Description                                                           |
| ----------------------------- | ------------------ | -------- | --------------------------------------------------------------------- |
| **Third-party account**       | Cloudflare account | Yes      | The Cloudflare account used to render the document.                   |
| **HTML**                      | String             | Yes      | The complete HTML document or fragment to render.                     |
| **Wait For Selector**         | String             | No       | A CSS selector that must appear before the PDF is captured.           |
| **Wait Time**                 | Number             | No       | Extra time to wait after rendering, from `0` to `30000` milliseconds. |
| **Viewport Width**            | Number             | No       | Browser viewport width, up to `1920`. Defaults to `1920`.             |
| **Viewport Height**           | Number             | No       | Browser viewport height, up to `1080`. Defaults to `1080`.            |
| **JavaScript Code**           | String             | No       | JavaScript inserted into the rendered document.                       |
| **Additional API Parameters** | Object             | No       | Extra Browser Rendering API fields, such as PDF-specific options.     |

## Output

| Output       | Type | Description                       |
| ------------ | ---- | --------------------------------- |
| **PDF File** | File | The rendered `page.pdf` document. |

<Tip>
  Put print-specific rules in the HTML with `@media print`. Page size, margins,
  headers, and footers can be supplied through **Additional API Parameters**
  when supported by Cloudflare's PDF endpoint.
</Tip>

External stylesheets, fonts, and images must be reachable from Cloudflare's
browser. For the most portable document, use absolute URLs or embed the assets
directly in the HTML.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Fonts or images are missing">
    Replace local and relative asset paths with public absolute URLs, or embed
    the asset in the HTML. The remote browser cannot access files on your
    computer or private network.
  </Accordion>

  <Accordion title="The PDF was captured too early">
    Set **Wait For Selector** to an element created after rendering finishes, or
    add a small **Wait Time**.
  </Accordion>
</AccordionGroup>
