# HTML to PDF - Templates, Bulk Invoices, Merge & Page Numbers (`digivibetech/html-to-pdf`) Actor

Turn HTML, URLs or a template plus data rows into PDFs: bulk invoices and reports, headers and footers with page numbers, custom page sizes, watermark, merge into one PDF. $1.50 per 1,000 PDFs.

- **URL**: https://apify.com/digivibetech/html-to-pdf.md
- **Developed by:** [DigiVibeTech](https://apify.com/digivibetech) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 pdf createds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

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 examples already wired to this Actor's own input schema, see the [API](#api) section below.

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`).

# README

## HTML to PDF - Templates, Bulk Invoices, Merge & Page Numbers

**HTML to PDF** — turn HTML, URLs or a template plus data rows into PDFs: bulk invoices and reports, headers and footers with page numbers, custom page sizes, watermark, merge into one PDF.

> **Try it free:** press **Start** — the prefilled input runs a small real job (a few items at $0.002 each). Apify's free plan includes monthly platform credit, so a first test costs you nothing. You can also set a maximum cost per run.

- **What you get:** `fileName`, `pages`, `bytes`, `title`, `source`, `url`
- **Who it's for:** developers, finance/back-office teams and agencies
- **Price:** $0.0015 per pdf created
- **Data source:** Renders only the HTML, templates and URLs you supply.

### What is HTML to PDF?

Make PDFs from HTML with a real Chrome browser. Three ways in:

1. **Template + data rows.** Write the HTML once with `{{ fields }}`, give a list of rows, get one PDF per row. Made for invoices, certificates, packing slips and reports.
2. **Raw HTML.** One complete HTML document to one PDF.
3. **URLs.** Save public web pages as PDF.

### ✅ Why this one

- Bulk from data: one template plus rows of data gives one PDF per row, for example invoices. The most used HTML to PDF actor on the Store converts one HTML string per run.
- Merge all PDFs into one file in input order (the merged file is free), add a watermark such as PAID, and name files from your data.
- $0.0015 per PDF with no start fee. A row with a missing field is reported and not charged.
- Any page size, including custom sizes such as 100 x 150 mm shipping labels, with page numbers in headers and footers.

### 📸 Real-run screenshots

From real run `aFPJrTliP0P1DxJuG` on Apify, 20 Nov 2026 (build 1.0.6). Images are rendered from that run's own input, dataset and charged events.

![Input of the real run](https://api.apify.com/v2/key-value-stores/8dx7mDMr71NbvtKdp/records/html-to-pdf-std-01-input.png)
![Results table (dataset)](https://api.apify.com/v2/key-value-stores/8dx7mDMr71NbvtKdp/records/html-to-pdf-std-02-results-table.png)
![One result item](https://api.apify.com/v2/key-value-stores/8dx7mDMr71NbvtKdp/records/html-to-pdf-std-03-result-item.png)
![Charged events and run cost](https://api.apify.com/v2/key-value-stores/8dx7mDMr71NbvtKdp/records/html-to-pdf-std-04-run-cost.png)
![First page of a generated PDF](https://api.apify.com/v2/key-value-stores/8dx7mDMr71NbvtKdp/records/html-to-pdf-std-05-pdf-page.png)

### ⬇️ What data you get

- **Bulk from data.** Jinja2 template syntax: `{{ customer }}`, `{% for line in lines %}`, `{{ total | money('EUR') }}`, `{{ lines | sum(attribute='price') }}`. Values are HTML-escaped and the template runs in a sandbox. A row with a missing field gets a clear error and is not charged.
- **Headers and footers on every page** with page numbers (`<span class='pageNumber'></span> of <span class='totalPages'></span>`), title and date.
- **Any page size.** A4, A3, A5, Letter, Legal, Tabloid, or a custom size such as 100 x 150 mm for shipping labels. Landscape, margins, scale, page ranges, CSS `@page` sizes, print or screen styles.
- **Merge into one PDF.** Next to the separate files you can get one combined PDF in input order. The merged file is free.
- **File names from your data**, for example `invoice-{{ number }}`. Duplicate names get `-2`, `-3`.
- **Watermark** text such as COPY or PAID on every page.
- **PDF properties**: title (from your input or the HTML `<title>`) and author.
- **Fonts**: emoji, Chinese, Japanese and Korean characters render instead of empty boxes.
- **Waiting for scripts**: wait for a CSS selector or a fixed delay, for pages that draw charts. JavaScript can be switched off.
- Output per PDF: file name, page count, size in bytes, title and a download link.

### 🎯 Use cases

- Generate bulk invoices or reports from a template and data rows
- Convert URLs to PDF with headers, footers and page numbers
- Merge many PDFs into one with a watermark

### ▶️ How to use

1. Open the actor; the input is prefilled with a small real example.
2. Replace it with your own input.
3. Press **Start**. Results appear in the **Output** tab (Overview view).
4. Download JSON, CSV or Excel, call the results via API, or schedule the actor.

### ⚙️ Input

```json
{
  "template": "<h1>Invoice {{ number }}</h1><p>{{ customer }}</p>{% for l in lines %}<p>{{ l.item }}: {{ l.price | money('EUR') }}</p>{% endfor %}",
  "dataRows": [
    {"number": "2026-001", "customer": "Acme", "lines": [{"item": "Hosting", "price": 120}]},
    {"number": "2026-002", "customer": "Beta", "lines": [{"item": "Support", "price": 75.5}]}
  ],
  "fileNameTemplate": "invoice-{{ number }}",
  "footerTemplate": "<div style='width:100%;text-align:center'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>",
  "mergeIntoOne": true
}
```

### ⬆️ Output

Each PDF is saved in the run's key-value store. The dataset has one row per PDF:

```json
{"fileName": "invoice-2026-001.pdf", "pages": 1, "bytes": 29013, "title": "Invoice 2026-001", "source": "template", "pdfUrl": "https://api.apify.com/v2/key-value-stores/.../records/invoice-2026-001.pdf"}
```

### 💵 Pricing and cost estimate

**$0.0015 per PDF created** ($1.50 per 1,000 PDFs), whatever the number of pages. No start fee. Not charged: the merged PDF, documents that fail (template errors, timeouts, HTTP errors), URLs that robots.txt does not allow. When your maximum cost per run is reached, the remaining documents are listed in ERRORS and not charged.

#### Cost estimate

| Pdf createds | Cost |
|---|---|
| 100 | $0.15 |
| 1,000 | $1.50 |
| 10,000 | $15.00 |

You pay only for these events: no subscription.

### 🔌 Integrations and API

Run it from **n8n, Make, Zapier, Clay** or any tool that can call an HTTP endpoint, connect a **webhook** to get notified when a run finishes, or let AI agents call it through the **Apify MCP server** (`mcp.apify.com`).

Run it and get the results in one call:

```bash
curl -X POST "https://api.apify.com/v2/acts/digivibetech~html-to-pdf/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"template": "<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>\n<div class=\"top\"><div><h1>Invoice {{ number }}</h1><div class=\"muted\">Issued {{ date }} - due {{ due }}</div></div><div style=\"text-align:right\"><b>{{ seller }}</b><div class=\"muted\">VAT {{ sellerVat }}</div></div></div>\n<p><b>Bill to:</b> {{ customer }}<br><span class=\"muted\">{{ customerCity }}</span></p>\n<table><tr><th>Description</th><th class=\"r\">Qty</th><th class=\"r\">Unit</th><th class=\"r\">Amount</th></tr>\n{% for l in lines %}<tr><td>{{ l.desc }}</td><td class=\"r\">{{ l.qty }}</td><td class=\"r\">{{ l.unit | money('EUR') }}</td><td class=\"r\">{{ (l.qty * l.unit) | money('EUR') }}</td></tr>{% endfor %}</table>\n<div class=\"tot\">Total excl. VAT: {{ total | money('EUR') }}</div>", "dataRows": [{"number": "2026-0141", "date": "2026-11-02", "due": "2026-12-02", "seller": "Northwind Studio B.V.", "sellerVat": "NL001234567B01", "customer": "Lindqvist Outdoor AB", "customerCity": "Gothenburg, Sweden", "lines": [{"desc": "Product photography (half day)", "qty": 1, "unit": 640}, {"desc": "Retouching, per image", "qty": 24, "unit": 9.5}, {"desc": "Usage licence web, 12 months", "qty": 1, "unit": 180}], "total": 1048}, {"number": "2026-0142", "date": "2026-11-05", "due": "2026-12-05", "seller": "Northwind Studio B.V.", "sellerVat": "NL001234567B01", "customer": "Café Moreau SARL", "customerCity": "Lyon, France", "lines": [{"desc": "Menu design, 2 pages", "qty": 1, "unit": 420}, {"desc": "Print-ready PDF export", "qty": 2, "unit": 35}], "total": 490}, {"number": "2026-0143", "date": "2026-11-09", "due": "2026-12-09", "seller": "Northwind Studio B.V.", "sellerVat": "NL001234567B01", "customer": "Brauerei Hofmann GmbH", "customerCity": "Bamberg, Germany", "lines": [{"desc": "Label design, 3 variants", "qty": 3, "unit": 260}, {"desc": "Colour proof round", "qty": 2, "unit": 45}, {"desc": "Rush fee", "qty": 1, "unit": 120}], "total": 1020}], "footerTemplate": "<div style='font-size:9px;width:100%;text-align:center;color:#6b7280'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>", "fileNameTemplate": "invoice-{{ number }}", "mergeIntoOne": true}'
```

Python (`pip install apify-client`):

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("digivibetech/html-to-pdf").call(run_input={"template": "<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>\n<div class=\"top\"><div><h1>Invoice {{ number }}</h1><div class=\"muted\">Issued {{ date }} - due {{ due }}</div></div><div style=\"text-align:right\"><b>{{ seller }}</b><div class=\"muted\">VAT {{ sellerVat }}</div></div></div>\n<p><b>Bill to:</b> {{ customer }}<br><span class=\"muted\">{{ customerCity }}</span></p>\n<table><tr><th>Description</th><th class=\"r\">Qty</th><th class=\"r\">Unit</th><th class=\"r\">Amount</th></tr>\n{% for l in lines %}<tr><td>{{ l.desc }}</td><td class=\"r\">{{ l.qty }}</td><td class=\"r\">{{ l.unit | money('EUR') }}</td><td class=\"r\">{{ (l.qty * l.unit) | money('EUR') }}</td></tr>{% endfor %}</table>\n<div class=\"tot\">Total excl. VAT: {{ total | money('EUR') }}</div>", "dataRows": [{"number": "2026-0141", "date": "2026-11-02", "due": "2026-12-02", "seller": "Northwind Studio B.V.", "sellerVat": "NL001234567B01", "customer": "Lindqvist Outdoor AB", "customerCity": "Gothenburg, Sweden", "lines": [{"desc": "Product photography (half day)", "qty": 1, "unit": 640}, {"desc": "Retouching, per image", "qty": 24, "unit": 9.5}, {"desc": "Usage licence web, 12 months", "qty": 1, "unit": 180}], "total": 1048}, {"number": "2026-0142", "date": "2026-11-05", "due": "2026-12-05", "seller": "Northwind Studio B.V.", "sellerVat": "NL001234567B01", "customer": "Café Moreau SARL", "customerCity": "Lyon, France", "lines": [{"desc": "Menu design, 2 pages", "qty": 1, "unit": 420}, {"desc": "Print-ready PDF export", "qty": 2, "unit": 35}], "total": 490}, {"number": "2026-0143", "date": "2026-11-09", "due": "2026-12-09", "seller": "Northwind Studio B.V.", "sellerVat": "NL001234567B01", "customer": "Brauerei Hofmann GmbH", "customerCity": "Bamberg, Germany", "lines": [{"desc": "Label design, 3 variants", "qty": 3, "unit": 260}, {"desc": "Colour proof round", "qty": 2, "unit": 45}, {"desc": "Rush fee", "qty": 1, "unit": 120}], "total": 1020}], "footerTemplate": "<div style='font-size:9px;width:100%;text-align:center;color:#6b7280'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>", "fileNameTemplate": "invoice-{{ number }}", "mergeIntoOne": true})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

### ⚠️ Limits

- Up to 5,000 documents per run. Use several runs for larger batches.
- URLs must be public. No logins, cookies or bypassing of access blocks. Pages that block automated access are reported, not retried in other ways.
- Images, fonts and styles in raw HTML must come from public addresses or be embedded as data URLs. Requests to private network addresses are blocked.
- Very long pages (hundreds of pages) need 4 GB memory or more.
- PDF/A, digital signatures, password protection and form fields are not supported.

### 🛡️ Data source, privacy and legality

Renders only the HTML, templates and URLs you supply.

You are responsible for using the results in line with the source's terms and data-protection law (for example GDPR).

### ❓ FAQ

#### How much does HTML to PDF cost?

$0.0015 per pdf created. See the cost estimate table above. There is no monthly fee.

#### Can I try it for free?

Yes. Press Start with the prefilled input: it runs a small real job (a few items at $0.002 each). Apify's free plan includes monthly platform credit, which covers a first test.

#### Is it legal to use HTML to PDF?

Renders only the HTML, templates and URLs you supply. Use the results lawfully (terms of the source, GDPR where it applies). This is not legal advice.

#### Can I use it through the API or an MCP server?

Yes. Every run is available through the Apify API and the official client libraries, and AI agents can call the actor through the Apify MCP server. See Integrations and API above.

#### Something does not work. Where do I get help?

Open an issue on the Issues tab or use [digivibetech.com/support](https://digivibetech.com/support/). Include the run ID so we can reproduce it.

### 📝 Changelog

#### 20 Nov 2026 — listing refresh

- README, listing text and input form restructured to the DigiVibeTech Apify quality standard v1. No feature or price change.

#### 1.0 — builds 1.0.2 to 1.0.5

- First build 2026-10-26, latest build 2026-10-30 (4 successful builds).

### 🧩 More DigiVibeTech actors

- [Bulk Image Converter & Compressor - WebP, AVIF, JPEG, PNG](https://apify.com/digivibetech/bulk-image-converter-compressor)
- [Bulk QR & Barcode Generator - PNG, SVG, Label PDFs](https://apify.com/digivibetech/bulk-qr-barcode-generator)
- [PDF OCR to Markdown - Scanned PDF & Image to Text for RAG](https://apify.com/digivibetech/document-to-markdown-ocr)
- [Bulk WHOIS & DNS Lookup - Domain Expiry, RDAP, SPF, DMARC](https://apify.com/digivibetech/domain-whois-rdap-dns)

*Maintained by DigiVibeTech. Questions or bugs: use the Issues tab or [digivibetech.com/support](https://digivibetech.com/support/); we reply within 2–5 business days.*

# Changelog

This Actor's version history is a separate document: https://apify.com/digivibetech/html-to-pdf/changelog.md

# Actor input Schema

## `template` (type: `string`):

HTML with {{ fields }}, {% for %} loops and filters (Jinja2 syntax, sandboxed, values HTML-escaped). One PDF is made per object in dataRows. Filter 'money' formats amounts: {{ total | money('EUR') }}.

## `dataRows` (type: `array`):

One object per PDF, used to fill the template. Example: \[{"number": "2026-001", "customer": "Acme", "total": 120}].

## `html` (type: `string`):

A complete HTML document to turn into one PDF. Images, fonts and styles may load from public URLs.

## `urls` (type: `array`):

Public web pages to save as PDF. robots.txt is respected; pages behind logins are not supported.

## `documents` (type: `array`):

Advanced: \[{"html": "...", "fileName": "a"}, {"url": "https://..."}, {"html": "<p>{{ x }}</p>", "data": {"x": 1}}].

## `pageFormat` (type: `string`):

Paper size. 'custom' uses pageWidth and pageHeight. A CSS @page size in the HTML wins when 'Use CSS page size' is on.

## `landscape` (type: `boolean`):

Rotate the page.

## `pageWidth` (type: `string`):

For pageFormat custom, e.g. 100mm, 4in, 600px.

## `pageHeight` (type: `string`):

For pageFormat custom, e.g. 150mm, 6in, 900px.

## `margin` (type: `object`):

{"top": "10mm", "right": "10mm", "bottom": "10mm", "left": "10mm"}. Plain numbers are millimetres.

## `scale` (type: `number`):

Zoom from 0.1 to 2.

## `headerTemplate` (type: `string`):

Repeated on every page. Use <span class='pageNumber'></span>, <span class='totalPages'></span>, <span class='title'></span>, <span class='date'></span>. Leave room with the top margin.

## `footerTemplate` (type: `string`):

Same as the header, for the bottom of every page. Example: Page <span class='pageNumber'></span> of <span class='totalPages'></span>.

## `printBackground` (type: `boolean`):

Include background colours and images.

## `preferCssPageSize` (type: `boolean`):

Let a CSS @page size rule in the HTML decide the paper size.

## `media` (type: `string`):

Render with print styles (default) or screen styles.

## `pageRanges` (type: `string`):

Keep only these pages, e.g. 1-3, 5. Empty keeps all.

## `watermark` (type: `string`):

Light diagonal text on every page, e.g. COPY or PAID. Max 60 characters.

## `fileNameTemplate` (type: `string`):

Name per PDF from the row data, e.g. invoice-{{ number }}. '.pdf' is added. Duplicates get -2, -3.

## `fileName` (type: `string`):

File name for the raw HTML document.

## `mergeIntoOne` (type: `boolean`):

Besides the separate files, save one combined PDF in input order. The merged file is free.

## `mergedFileName` (type: `string`):

Name of the combined PDF.

## `title` (type: `string`):

Document title stored in the PDF. Empty uses the HTML <title>.

## `author` (type: `string`):

Author field stored in the PDF properties.

## `baseUrl` (type: `string`):

Lets relative image and CSS paths in raw HTML load from your public site, e.g. https://yoursite.com/assets/.

## `waitForSelector` (type: `string`):

CSS selector to wait for before printing, for pages that draw charts with scripts.

## `javaScript` (type: `boolean`):

Turn off to print the HTML exactly as written.

## `delayMs` (type: `integer`):

Wait this long before printing (0-30000).

## `pageTimeoutSecs` (type: `integer`):

Maximum time to load one document (5-180).

## Actor input object example

```json
{
  "template": "<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>\n<div class=\"top\"><div><h1>Invoice {{ number }}</h1><div class=\"muted\">Issued {{ date }} - due {{ due }}</div></div><div style=\"text-align:right\"><b>{{ seller }}</b><div class=\"muted\">VAT {{ sellerVat }}</div></div></div>\n<p><b>Bill to:</b> {{ customer }}<br><span class=\"muted\">{{ customerCity }}</span></p>\n<table><tr><th>Description</th><th class=\"r\">Qty</th><th class=\"r\">Unit</th><th class=\"r\">Amount</th></tr>\n{% for l in lines %}<tr><td>{{ l.desc }}</td><td class=\"r\">{{ l.qty }}</td><td class=\"r\">{{ l.unit | money('EUR') }}</td><td class=\"r\">{{ (l.qty * l.unit) | money('EUR') }}</td></tr>{% endfor %}</table>\n<div class=\"tot\">Total excl. VAT: {{ total | money('EUR') }}</div>",
  "dataRows": [
    {
      "number": "2026-0141",
      "date": "2026-11-02",
      "due": "2026-12-02",
      "seller": "Northwind Studio B.V.",
      "sellerVat": "NL001234567B01",
      "customer": "Lindqvist Outdoor AB",
      "customerCity": "Gothenburg, Sweden",
      "lines": [
        {
          "desc": "Product photography (half day)",
          "qty": 1,
          "unit": 640
        },
        {
          "desc": "Retouching, per image",
          "qty": 24,
          "unit": 9.5
        },
        {
          "desc": "Usage licence web, 12 months",
          "qty": 1,
          "unit": 180
        }
      ],
      "total": 1048
    },
    {
      "number": "2026-0142",
      "date": "2026-11-05",
      "due": "2026-12-05",
      "seller": "Northwind Studio B.V.",
      "sellerVat": "NL001234567B01",
      "customer": "Café Moreau SARL",
      "customerCity": "Lyon, France",
      "lines": [
        {
          "desc": "Menu design, 2 pages",
          "qty": 1,
          "unit": 420
        },
        {
          "desc": "Print-ready PDF export",
          "qty": 2,
          "unit": 35
        }
      ],
      "total": 490
    },
    {
      "number": "2026-0143",
      "date": "2026-11-09",
      "due": "2026-12-09",
      "seller": "Northwind Studio B.V.",
      "sellerVat": "NL001234567B01",
      "customer": "Brauerei Hofmann GmbH",
      "customerCity": "Bamberg, Germany",
      "lines": [
        {
          "desc": "Label design, 3 variants",
          "qty": 3,
          "unit": 260
        },
        {
          "desc": "Colour proof round",
          "qty": 2,
          "unit": 45
        },
        {
          "desc": "Rush fee",
          "qty": 1,
          "unit": 120
        }
      ],
      "total": 1020
    }
  ],
  "pageFormat": "A4",
  "landscape": false,
  "margin": {
    "top": "10mm",
    "right": "10mm",
    "bottom": "10mm",
    "left": "10mm"
  },
  "scale": 1,
  "footerTemplate": "<div style='font-size:9px;width:100%;text-align:center;color:#6b7280'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>",
  "printBackground": true,
  "preferCssPageSize": true,
  "media": "print",
  "fileNameTemplate": "invoice-{{ number }}",
  "mergeIntoOne": true,
  "mergedFileName": "merged.pdf",
  "javaScript": true,
  "delayMs": 0,
  "pageTimeoutSecs": 30
}
```

# Actor output Schema

## `pdfs` (type: `string`):

No description

## `files` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "template": `<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>
<div class="top"><div><h1>Invoice {{ number }}</h1><div class="muted">Issued {{ date }} - due {{ due }}</div></div><div style="text-align:right"><b>{{ seller }}</b><div class="muted">VAT {{ sellerVat }}</div></div></div>
<p><b>Bill to:</b> {{ customer }}<br><span class="muted">{{ customerCity }}</span></p>
<table><tr><th>Description</th><th class="r">Qty</th><th class="r">Unit</th><th class="r">Amount</th></tr>
{% for l in lines %}<tr><td>{{ l.desc }}</td><td class="r">{{ l.qty }}</td><td class="r">{{ l.unit | money('EUR') }}</td><td class="r">{{ (l.qty * l.unit) | money('EUR') }}</td></tr>{% endfor %}</table>
<div class="tot">Total excl. VAT: {{ total | money('EUR') }}</div>`,
    "dataRows": [
        {
            "number": "2026-0141",
            "date": "2026-11-02",
            "due": "2026-12-02",
            "seller": "Northwind Studio B.V.",
            "sellerVat": "NL001234567B01",
            "customer": "Lindqvist Outdoor AB",
            "customerCity": "Gothenburg, Sweden",
            "lines": [
                {
                    "desc": "Product photography (half day)",
                    "qty": 1,
                    "unit": 640
                },
                {
                    "desc": "Retouching, per image",
                    "qty": 24,
                    "unit": 9.5
                },
                {
                    "desc": "Usage licence web, 12 months",
                    "qty": 1,
                    "unit": 180
                }
            ],
            "total": 1048
        },
        {
            "number": "2026-0142",
            "date": "2026-11-05",
            "due": "2026-12-05",
            "seller": "Northwind Studio B.V.",
            "sellerVat": "NL001234567B01",
            "customer": "Café Moreau SARL",
            "customerCity": "Lyon, France",
            "lines": [
                {
                    "desc": "Menu design, 2 pages",
                    "qty": 1,
                    "unit": 420
                },
                {
                    "desc": "Print-ready PDF export",
                    "qty": 2,
                    "unit": 35
                }
            ],
            "total": 490
        },
        {
            "number": "2026-0143",
            "date": "2026-11-09",
            "due": "2026-12-09",
            "seller": "Northwind Studio B.V.",
            "sellerVat": "NL001234567B01",
            "customer": "Brauerei Hofmann GmbH",
            "customerCity": "Bamberg, Germany",
            "lines": [
                {
                    "desc": "Label design, 3 variants",
                    "qty": 3,
                    "unit": 260
                },
                {
                    "desc": "Colour proof round",
                    "qty": 2,
                    "unit": 45
                },
                {
                    "desc": "Rush fee",
                    "qty": 1,
                    "unit": 120
                }
            ],
            "total": 1020
        }
    ],
    "footerTemplate": "<div style='font-size:9px;width:100%;text-align:center;color:#6b7280'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>",
    "fileNameTemplate": "invoice-{{ number }}",
    "mergeIntoOne": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("digivibetech/html-to-pdf").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "template": """<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>
<div class=\"top\"><div><h1>Invoice {{ number }}</h1><div class=\"muted\">Issued {{ date }} - due {{ due }}</div></div><div style=\"text-align:right\"><b>{{ seller }}</b><div class=\"muted\">VAT {{ sellerVat }}</div></div></div>
<p><b>Bill to:</b> {{ customer }}<br><span class=\"muted\">{{ customerCity }}</span></p>
<table><tr><th>Description</th><th class=\"r\">Qty</th><th class=\"r\">Unit</th><th class=\"r\">Amount</th></tr>
{% for l in lines %}<tr><td>{{ l.desc }}</td><td class=\"r\">{{ l.qty }}</td><td class=\"r\">{{ l.unit | money('EUR') }}</td><td class=\"r\">{{ (l.qty * l.unit) | money('EUR') }}</td></tr>{% endfor %}</table>
<div class=\"tot\">Total excl. VAT: {{ total | money('EUR') }}</div>""",
    "dataRows": [
        {
            "number": "2026-0141",
            "date": "2026-11-02",
            "due": "2026-12-02",
            "seller": "Northwind Studio B.V.",
            "sellerVat": "NL001234567B01",
            "customer": "Lindqvist Outdoor AB",
            "customerCity": "Gothenburg, Sweden",
            "lines": [
                {
                    "desc": "Product photography (half day)",
                    "qty": 1,
                    "unit": 640,
                },
                {
                    "desc": "Retouching, per image",
                    "qty": 24,
                    "unit": 9.5,
                },
                {
                    "desc": "Usage licence web, 12 months",
                    "qty": 1,
                    "unit": 180,
                },
            ],
            "total": 1048,
        },
        {
            "number": "2026-0142",
            "date": "2026-11-05",
            "due": "2026-12-05",
            "seller": "Northwind Studio B.V.",
            "sellerVat": "NL001234567B01",
            "customer": "Café Moreau SARL",
            "customerCity": "Lyon, France",
            "lines": [
                {
                    "desc": "Menu design, 2 pages",
                    "qty": 1,
                    "unit": 420,
                },
                {
                    "desc": "Print-ready PDF export",
                    "qty": 2,
                    "unit": 35,
                },
            ],
            "total": 490,
        },
        {
            "number": "2026-0143",
            "date": "2026-11-09",
            "due": "2026-12-09",
            "seller": "Northwind Studio B.V.",
            "sellerVat": "NL001234567B01",
            "customer": "Brauerei Hofmann GmbH",
            "customerCity": "Bamberg, Germany",
            "lines": [
                {
                    "desc": "Label design, 3 variants",
                    "qty": 3,
                    "unit": 260,
                },
                {
                    "desc": "Colour proof round",
                    "qty": 2,
                    "unit": 45,
                },
                {
                    "desc": "Rush fee",
                    "qty": 1,
                    "unit": 120,
                },
            ],
            "total": 1020,
        },
    ],
    "footerTemplate": "<div style='font-size:9px;width:100%;text-align:center;color:#6b7280'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>",
    "fileNameTemplate": "invoice-{{ number }}",
    "mergeIntoOne": True,
}

# Run the Actor and wait for it to finish
run = client.actor("digivibetech/html-to-pdf").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "template": "<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>\\n<div class=\\"top\\"><div><h1>Invoice {{ number }}</h1><div class=\\"muted\\">Issued {{ date }} - due {{ due }}</div></div><div style=\\"text-align:right\\"><b>{{ seller }}</b><div class=\\"muted\\">VAT {{ sellerVat }}</div></div></div>\\n<p><b>Bill to:</b> {{ customer }}<br><span class=\\"muted\\">{{ customerCity }}</span></p>\\n<table><tr><th>Description</th><th class=\\"r\\">Qty</th><th class=\\"r\\">Unit</th><th class=\\"r\\">Amount</th></tr>\\n{% for l in lines %}<tr><td>{{ l.desc }}</td><td class=\\"r\\">{{ l.qty }}</td><td class=\\"r\\">{{ l.unit | money('\''EUR'\'') }}</td><td class=\\"r\\">{{ (l.qty * l.unit) | money('\''EUR'\'') }}</td></tr>{% endfor %}</table>\\n<div class=\\"tot\\">Total excl. VAT: {{ total | money('\''EUR'\'') }}</div>",
  "dataRows": [
    {
      "number": "2026-0141",
      "date": "2026-11-02",
      "due": "2026-12-02",
      "seller": "Northwind Studio B.V.",
      "sellerVat": "NL001234567B01",
      "customer": "Lindqvist Outdoor AB",
      "customerCity": "Gothenburg, Sweden",
      "lines": [
        {
          "desc": "Product photography (half day)",
          "qty": 1,
          "unit": 640
        },
        {
          "desc": "Retouching, per image",
          "qty": 24,
          "unit": 9.5
        },
        {
          "desc": "Usage licence web, 12 months",
          "qty": 1,
          "unit": 180
        }
      ],
      "total": 1048
    },
    {
      "number": "2026-0142",
      "date": "2026-11-05",
      "due": "2026-12-05",
      "seller": "Northwind Studio B.V.",
      "sellerVat": "NL001234567B01",
      "customer": "Café Moreau SARL",
      "customerCity": "Lyon, France",
      "lines": [
        {
          "desc": "Menu design, 2 pages",
          "qty": 1,
          "unit": 420
        },
        {
          "desc": "Print-ready PDF export",
          "qty": 2,
          "unit": 35
        }
      ],
      "total": 490
    },
    {
      "number": "2026-0143",
      "date": "2026-11-09",
      "due": "2026-12-09",
      "seller": "Northwind Studio B.V.",
      "sellerVat": "NL001234567B01",
      "customer": "Brauerei Hofmann GmbH",
      "customerCity": "Bamberg, Germany",
      "lines": [
        {
          "desc": "Label design, 3 variants",
          "qty": 3,
          "unit": 260
        },
        {
          "desc": "Colour proof round",
          "qty": 2,
          "unit": 45
        },
        {
          "desc": "Rush fee",
          "qty": 1,
          "unit": 120
        }
      ],
      "total": 1020
    }
  ],
  "footerTemplate": "<div style='\''font-size:9px;width:100%;text-align:center;color:#6b7280'\''>Page <span class='\''pageNumber'\''></span> of <span class='\''totalPages'\''></span></div>",
  "fileNameTemplate": "invoice-{{ number }}",
  "mergeIntoOne": true
}' |
apify call digivibetech/html-to-pdf --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,digivibetech/html-to-pdf"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bajmOiqEKhk9Tad4R/builds/9GZcUJoR7e3fBJAQL/openapi.json
