# HTML to PDF: Render an Invoice Template

**Use case:** 

Renders a small HTML invoice into an A4 PDF without hosting it anywhere. Paste your own HTML and CSS to turn templates, reports or receipts into PDFs from an API call.

## Input

```json
{
  "urls": [
    "https://apify.com",
    "en.wikipedia.org/wiki/Web_scraping"
  ],
  "devices": [
    "desktop",
    "mobile"
  ],
  "format": "pdf",
  "fullPage": true,
  "quality": 80,
  "selector": "#pricing",
  "html": "<html><head><style>body{font-family:Helvetica,Arial,sans-serif;margin:40px;color:#222}h1{margin:0 0 4px}table{width:100%;border-collapse:collapse;margin-top:24px}td,th{border-bottom:1px solid #ddd;padding:8px;text-align:left}.r{text-align:right}</style></head><body><h1>Invoice #1042</h1><p>Issued 8 November 2026</p><table><tr><th>Item</th><th class='r'>Qty</th><th class='r'>Price</th></tr><tr><td>Website audit</td><td class='r'>1</td><td class='r'>$400.00</td></tr><tr><td>Monthly hosting</td><td class='r'>3</td><td class='r'>$60.00</td></tr><tr><th>Total</th><td></td><th class='r'>$580.00</th></tr></table></body></html>",
  "maxHeight": 20000,
  "waitUntil": "load",
  "delayMs": 500,
  "scrollToLoadLazyContent": true,
  "navigationTimeoutSecs": 45,
  "dismissCookieBanners": true,
  "hideSelectors": [
    "#chat-widget",
    ".newsletter-popup"
  ],
  "blockAds": false,
  "darkMode": false,
  "disableAnimations": true,
  "pdfFormat": "A4",
  "pdfLandscape": false,
  "pdfMargin": "15mm",
  "pdfPrintBackground": true,
  "pdfMediaType": "screen",
  "pdfScale": 1,
  "captureErrorPages": false,
  "maxConcurrency": 4,
  "maxRetries": 1,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

## Output

```json
{
  "status": {
    "label": "Status",
    "format": "string"
  },
  "url": {
    "label": "URL",
    "format": "string"
  },
  "device": {
    "label": "Device",
    "format": "string"
  },
  "format": {
    "label": "Format",
    "format": "string"
  },
  "fileUrl": {
    "label": "File",
    "format": "string"
  },
  "fileKey": {
    "label": "File key",
    "format": "string"
  },
  "bytes": {
    "label": "Bytes",
    "format": "integer"
  },
  "pdfPages": {
    "label": "PDF pages",
    "format": "integer"
  },
  "finalUrl": {
    "label": "Final URL",
    "format": "string"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The Website Screenshot & PDF API: Full Page, Mobile, Cookie-Free Actor is ready to run with the inputs already set for "HTML to PDF: Render an Invoice Template". [Sign up or log in](https://console.apify.com/create-task-from-example/5Zzd1EjCqZK7lb8rb) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "HTML to PDF: Render an Invoice Template" task

The Website Screenshot & PDF API: Full Page, Mobile, Cookie-Free Actor will start running based on the input automatically. You can also change all the input fields, like URLs, devices, and more, to match your specific use case.

### 3. Receive the "HTML to PDF: Render an Invoice Template" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as status, URL, device, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "HTML to PDF: Render an Invoice Template" task via API](https://apify.com/tidewell/website-screenshot-pdf.md).

## FAQ

### How much does a capture cost?

$0.002 per PNG, JPEG or WebP screenshot and $0.003 per PDF, plus a small start fee per run. Pages that fail to load are not charged.

### Where are the files saved?

In the run's key-value store. Each dataset row has a public fileUrl you can download or pass to another tool, plus the size, dimensions and HTTP status.

### Can the HTML load images and fonts?

Yes, from absolute URLs such as https links to your logo or a web font. Relative paths have no base URL to load from, so use absolute links or inline data URIs.

### Can I render HTML to an image instead?

Yes. Set format to png, jpeg or webp, and pick a custom device with viewportWidth and viewportHeight.

## About this Actor

This example demonstrates how to use [Website Screenshot & PDF API: Full Page, Mobile, Cookie-Free](https://apify.com/tidewell/website-screenshot-pdf.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/tidewell/website-screenshot-pdf.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/tidewell/website-screenshot-pdf.md

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).
