# HTML to PDF: render raw HTML (invoice, report) to A4 PDF

**Use case:** 

Renders your own HTML string, with its CSS, into a paginated A4 PDF with page numbers. No hosting needed: paste the HTML in the input. Example: a fictional one-page invoice. Good for invoices, reports and receipts generated by your app. About $0.003 per document: $0.001 start plus $0.002 per PDF. Up to 2 MB of HTML.

## Input

```json
{
  "urls": [
    {
      "url": "https://example.com"
    }
  ],
  "html": "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><title>Invoice INV-2026-001</title>\n<style>body{font-family:Arial,Helvetica,sans-serif;color:#1f2933;margin:0}h1{font-size:28px;margin:0 0 4px}\n.muted{color:#6b7280}table{width:100%;border-collapse:collapse;margin-top:24px}th,td{padding:8px;border-bottom:1px solid #e5e7eb;text-align:left}\ntd.r,th.r{text-align:right}.total{font-size:18px;font-weight:bold}</style></head><body>\n<h1>Invoice INV-2026-001</h1><p class=\"muted\">Example Supplies Ltd. &middot; Issued 2026-10-19 &middot; Due 2026-11-18</p>\n<p><strong>Bill to:</strong> Demo Customer Inc.</p>\n<table><thead><tr><th>Item</th><th class=\"r\">Qty</th><th class=\"r\">Unit</th><th class=\"r\">Amount</th></tr></thead><tbody>\n<tr><td>Website screenshots (1,000 files)</td><td class=\"r\">1</td><td class=\"r\">$2.00</td><td class=\"r\">$2.00</td></tr>\n<tr><td>Visual diff checks</td><td class=\"r\">500</td><td class=\"r\">$0.001</td><td class=\"r\">$0.50</td></tr>\n</tbody><tfoot><tr><td colspan=\"3\" class=\"r total\">Total</td><td class=\"r total\">$2.50</td></tr></tfoot></table>\n<p class=\"muted\">Sample document generated for a demo. Not a real invoice.</p></body></html>",
  "urlField": "url",
  "sitemapUrl": "https://example.com/sitemap.xml",
  "maxUrls": 100,
  "formats": [
    "pdf"
  ],
  "fullPage": false,
  "device": "desktop",
  "width": 1280,
  "height": 720,
  "deviceScaleFactor": 2,
  "selector": "article",
  "clip": {
    "x": 0,
    "y": 0,
    "width": 800,
    "height": 600
  },
  "quality": 80,
  "omitBackground": false,
  "waitUntil": "load",
  "delayMs": 500,
  "timeoutSecs": 30,
  "darkMode": false,
  "hideCookieBanners": true,
  "acceptCookies": false,
  "blockAds": true,
  "hideSelectors": [
    ".newsletter-modal"
  ],
  "blurSelectors": [
    ".account-email"
  ],
  "pdf": {
    "format": "A4",
    "landscape": false,
    "printBackground": true,
    "scale": 1,
    "pageNumbers": true,
    "margin": {
      "top": "1cm",
      "right": "1cm",
      "bottom": "1.4cm",
      "left": "1cm"
    }
  },
  "compareWithPrevious": false,
  "baselineStoreName": "rigel-screenshot-baselines",
  "diffThreshold": 0.1,
  "captureErrorPages": false,
  "cookies": "<YOUR_SECRET>",
  "headers": "<YOUR_SECRET>",
  "proxyUrl": "<YOUR_SECRET>"
}
```

## Output

```json
{
  "url": {
    "label": "URL",
    "format": "string"
  },
  "status": {
    "label": "Status",
    "format": "string"
  },
  "httpStatus": {
    "label": "HTTP status",
    "format": "integer"
  },
  "finalUrl": {
    "label": "Final URL",
    "format": "string"
  },
  "device": {
    "label": "Device",
    "format": "string"
  },
  "page.title": {
    "label": "Title",
    "format": "string"
  },
  "page.loadMs": {
    "label": "Load ms",
    "format": "integer"
  },
  "charged.capture": {
    "label": "Captures",
    "format": "integer"
  },
  "charged.visual-diff": {
    "label": "Diffs",
    "format": "integer"
  },
  "capturedAt": {
    "label": "Captured at",
    "format": "string"
  }
}
```

## How it works

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

The Website Screenshot API, Full Page & URL/HTML to PDF Actor is ready to run with the inputs already set for "HTML to PDF: render raw HTML (invoice, report) to A4 PDF". [Sign up or log in](https://console.apify.com/create-task-from-example/wPDpYzpZ64QfonysJ) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "HTML to PDF: render raw HTML (invoice, report) to A4 PDF" task

The Website Screenshot API, Full Page & URL/HTML to PDF Actor will start running based on the input automatically. You can also change all the input fields, like URLs, raw html, and more, to match your specific use case.

### 3. Receive the "HTML to PDF: render raw HTML (invoice, report) to A4 PDF" 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 URL, status, HTTP status, 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 raw HTML (invoice, report) to A4 PDF" task via API](https://apify.com/rigel/website-screenshot-pdf.md).

## About this Actor

This example demonstrates how to use [Website Screenshot API, Full Page & URL/HTML to PDF](https://apify.com/rigel/website-screenshot-pdf.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/rigel/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/rigel/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`).
