# HTML to PDF Converter (`automation-lab/html-to-pdf-converter`) Actor

Convert HTML content or web pages to PDF documents. Supports raw HTML strings, single URLs, and bulk URL lists. Full control over page size, margins, orientation, headers, and footers.

- **URL**: https://apify.com/automation-lab/html-to-pdf-converter.md
- **Developed by:** [Stas Persiianenko](https://apify.com/automation-lab) (community)
- **Categories:** Developer tools, Other
- **Stats:** 3 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## HTML to PDF Converter

Convert HTML content and web pages to PDF documents with full control over formatting, margins, headers, footers, and page size. Supports raw HTML strings, single URLs, and bulk URL lists — no API key or login required.

### What does HTML to PDF Converter do?

**HTML to PDF Converter** turns any web page or HTML string into a pixel-perfect PDF document using a real Chromium browser (via Playwright). It renders JavaScript, CSS, and dynamic content exactly as it appears in your browser — then exports it as a PDF stored in Apify's key-value store, ready to download or integrate via API.

You can convert:
- 📄 **Raw HTML strings** — paste your own HTML/CSS markup and get a PDF instantly
- 🌐 **Single URLs** — convert any public web page to PDF
- 📋 **Lists of URLs** — batch-convert multiple pages into separate PDF files

Unlike simpler HTML-to-PDF tools that only handle static markup, this actor loads the full page in a real browser, so CSS animations, web fonts, background images, and JavaScript-rendered content all render correctly.

### Who is HTML to PDF Converter for?

**Developers and teams automating document workflows:**
- Generate PDF reports, invoices, or statements from HTML templates
- Archive web pages as PDFs for compliance or record-keeping
- Convert dashboards or data visualizations to shareable PDF files

**Content teams and researchers:**
- Save web articles and documentation as PDFs for offline reading
- Capture a snapshot of a web page before it changes
- Convert multiple web pages into PDF for review or distribution

**Business operations teams:**
- Generate branded PDFs from internal HTML pages or email templates
- Archive receipts, invoices, and order confirmations as PDFs
- Automate end-of-month reporting by converting data dashboards to PDF

**QA and testing engineers:**
- Capture a visual record of web pages at a specific point in time
- Generate test reports in PDF format from HTML output

### Why use HTML to PDF Converter?

- ✅ **Full browser rendering** — uses Chromium (Playwright), so all CSS, fonts, and JS-rendered content render correctly
- ✅ **No API key required** — works out of the box on Apify
- ✅ **Batch conversion** — convert a list of URLs in a single run
- ✅ **Full formatting control** — page size (A4, Letter, Legal, Tabloid, etc.), margins, orientation, scale, headers/footers
- ✅ **HTML string support** — paste raw HTML/CSS markup directly without needing a server
- ✅ **Dynamic content support** — wait for specific CSS selectors or add custom delays before PDF generation
- ✅ **Background graphics** — includes background colors, images, and gradients in the output
- ✅ **Full-page PDFs** — optionally capture the entire scrollable page height instead of standard page breaks
- ✅ **PDF stored in key-value store** — each PDF is directly accessible via URL, no extra download steps

### What data can you extract?

Each run produces:

| Output field | Description |
|---|---|
| `pdfKey` | Filename of the PDF in the key-value store (e.g., `output.pdf`) |
| `pdfUrl` | Direct download URL for the PDF |
| `fileSizeKb` | PDF file size in kilobytes |
| `source` | The original URL or "(HTML string)" |
| `success` | Whether the conversion succeeded |
| `error` | Error message if conversion failed |

PDFs are stored in the run's key-value store and accessible via the Apify API or the Console UI.

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

HTML to PDF Converter uses **pay-per-event (PPE) pricing** — you only pay for what you convert.

| Plan | Price per page |
|---|---|
| Free ($5 credit) | $0.00575 |
| Starter ($29/mo) | $0.005 |
| Scale ($199/mo) | $0.0039 |
| Business ($999/mo) | $0.003 |

Plus a one-time start fee of **$0.005** per run.

**Real-world cost examples:**

| Use case | Pages | Estimated cost |
|---|---|---|
| Single invoice or report | 1 | ~$0.01 |
| Weekly batch of 10 pages | 10 | ~$0.055 |
| Daily batch of 50 pages | 50 | ~$0.255 |
| Monthly archive of 200 pages | 200 | ~$1.005 |

**Free plan:** With $5 in free credits, you can convert approximately **860 pages** before any paid plan is needed.

### How to convert HTML to PDF

1. Go to the [HTML to PDF Converter](https://apify.com/automation-lab/html-to-pdf-converter) page on Apify Store
2. Click **Try for free**
3. Choose your **Input type**: HTML string, Single URL, or List of URLs
4. Enter your HTML content or URL(s)
5. Set your PDF options: page format, margins, orientation, headers/footers
6. Click **Start** to begin the conversion
7. When the run finishes, find your PDFs in the **Key-value store** tab
8. Download directly or use the PDF URL in your workflow

**Example: Convert a single web page**
```json
{
  "inputType": "url",
  "url": "https://example.com",
  "pageFormat": "A4",
  "printBackground": true
}
````

**Example: Convert raw HTML to PDF with custom margins**

```json
{
  "inputType": "html",
  "html": "<html><body><h1>Invoice #1234</h1><p>Amount: $100.00</p></body></html>",
  "pageFormat": "Letter",
  "marginTop": "20mm",
  "marginBottom": "20mm",
  "marginLeft": "25mm",
  "marginRight": "25mm"
}
```

**Example: Batch-convert multiple URLs**

```json
{
  "inputType": "urls",
  "urls": [
    "https://example.com/page-1",
    "https://example.com/page-2",
    "https://example.com/page-3"
  ],
  "pageFormat": "A4",
  "outputFileName": "report"
}
```

### Input parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `inputType` | string | `url` | What to convert: `html`, `url`, or `urls` |
| `html` | string | — | Raw HTML content to convert (when `inputType` is `html`) |
| `url` | string | — | URL to convert (when `inputType` is `url`) |
| `urls` | array | — | List of URLs to convert (when `inputType` is `urls`) |
| `pageFormat` | string | `A4` | Page size: `A4`, `A3`, `A5`, `Letter`, `Legal`, `Tabloid` |
| `landscape` | boolean | `false` | Use landscape orientation |
| `marginTop` | string | `10mm` | Top margin (e.g., `10mm`, `1cm`, `0.5in`) |
| `marginBottom` | string | `10mm` | Bottom margin |
| `marginLeft` | string | `10mm` | Left margin |
| `marginRight` | string | `10mm` | Right margin |
| `printBackground` | boolean | `true` | Include background colors and images |
| `scale` | number | `1` | Page scale factor (0.1–2.0) |
| `displayHeaderFooter` | boolean | `false` | Show header/footer templates |
| `headerTemplate` | string | — | HTML template for page header |
| `footerTemplate` | string | — | HTML template for page footer |
| `waitForSelector` | string | — | CSS selector to wait for before PDF generation |
| `waitForTimeout` | integer | `0` | Extra wait time (ms) before PDF generation |
| `outputFileName` | string | `output` | Prefix for PDF filenames |
| `fullPage` | boolean | `false` | Capture full scrollable page height |

### Output examples

Each converted page produces one dataset record:

```json
{
  "index": 1,
  "source": "https://example.com",
  "pdfKey": "output.pdf",
  "pdfUrl": "https://api.apify.com/v2/key-value-stores/STORE_ID/records/output.pdf",
  "fileSizeKb": 245.3,
  "success": true,
  "error": null
}
```

For batch conversions (`inputType: urls`), PDFs are named `{outputFileName}-001.pdf`, `{outputFileName}-002.pdf`, etc.

### Tips for best results

- 💡 **Start small**: Test with a single URL before batch-converting many pages
- 🎨 **Background images not showing?** Make sure `printBackground: true` is set
- ⏳ **Dynamic content not loaded?** Use `waitForSelector` with a CSS class that appears after JavaScript finishes loading, or add `waitForTimeout` (e.g., `2000` for 2 seconds)
- 📐 **Full-page captures**: Set `fullPage: true` to avoid page breaks and get one continuous PDF
- 📝 **Headers and footers**: Set `displayHeaderFooter: true` and provide HTML templates with `.pageNumber` and `.totalPages` CSS classes
- 💾 **Custom filenames**: Use `outputFileName` to set a descriptive prefix for your PDFs
- 🔢 **Scaling**: Use `scale: 0.8` to fit more content per page, or `scale: 1.2` to increase text size

### Integrations

**HTML to PDF Converter → Google Drive:**
Schedule the actor to convert your weekly reports to PDF, then use a Zapier webhook to save them to Google Drive automatically. Perfect for archiving or sharing with stakeholders who need offline copies.

**HTML to PDF Converter → Email:**
Convert HTML email templates to PDF for preview and approval. Use the PDF URL in a Make (Integromat) workflow to attach it to an email or Slack notification.

**HTML to PDF Converter → Slack notifications:**
Trigger the actor via API after deploying a dashboard update. Send the PDF URL to a Slack channel so your team always has the latest report as a shareable PDF.

**Scheduled page archiving:**
Set a daily cron schedule on Apify to automatically archive web pages that change frequently (product pages, news articles, pricing pages). Each run stores a dated PDF snapshot.

**Invoice generation pipeline:**
Use the HTML string input mode to generate PDFs from invoice HTML templates. Combine with Apify's API to call this actor from your backend after each payment — get a PDF URL in the response to store in your database.

### Using the Apify API

Use the Apify API to run HTML to PDF Converter programmatically from your own code.

#### Node.js

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

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });

const run = await client.actor('automation-lab/html-to-pdf-converter').call({
  inputType: 'url',
  url: 'https://example.com',
  pageFormat: 'A4',
  printBackground: true,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log('PDF URL:', items[0].pdfUrl);
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient(token='YOUR_APIFY_TOKEN')

run = client.actor('automation-lab/html-to-pdf-converter').call(run_input={
    'inputType': 'url',
    'url': 'https://example.com',
    'pageFormat': 'A4',
    'printBackground': True,
})

items = client.dataset(run['defaultDatasetId']).list_items().items
print('PDF URL:', items[0]['pdfUrl'])
```

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/automation-lab~html-to-pdf-converter/runs?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "inputType": "url",
    "url": "https://example.com",
    "pageFormat": "A4",
    "printBackground": true
  }'
```

### Use with AI agents via MCP

HTML to PDF Converter is available as a tool for AI assistants that support the [Model Context Protocol (MCP)](https://docs.apify.com/platform/integrations/mcp).

Add the Apify MCP server to your AI client — this gives you access to all Apify actors, including this one:

#### Setup for Claude Code

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=automation-lab/html-to-pdf-converter"
```

#### Setup for Claude Desktop, Cursor, or VS Code

Add this to your MCP config file:

```json
{
    "mcpServers": {
        "apify": {
            "url": "https://mcp.apify.com?tools=automation-lab/html-to-pdf-converter"
        }
    }
}
```

Your AI assistant will use OAuth to authenticate with your Apify account on first use.

#### Example prompts

Once connected, try asking your AI assistant:

- "Use automation-lab/html-to-pdf-converter to convert https://example.com/invoice to a PDF in Letter format"
- "Convert this HTML invoice template to a PDF with 20mm margins and a footer showing page numbers"
- "Batch-convert these 5 URLs to PDFs: \[list] and store them with the filename prefix 'monthly-report'"

Learn more in the [Apify MCP documentation](https://docs.apify.com/platform/integrations/mcp).

### Is it legal to convert web pages to PDF?

Yes, converting publicly accessible web pages to PDF for personal use, archiving, or internal purposes is generally considered legal in most jurisdictions. Always respect the website's `robots.txt` and terms of service. Avoid bulk-converting copyrighted content for redistribution.

HTML to PDF Converter accesses only the URLs and HTML content you provide — it does not crawl links or access private pages unless you provide credentials. Always ensure you have the right to capture the content you're converting.

### FAQ

**How fast does conversion take?**
A single page typically converts in 5–20 seconds depending on the page's complexity, JavaScript rendering time, and network conditions. Batch jobs convert pages sequentially — a 10-page batch takes roughly 1–3 minutes.

**How much does it cost per PDF?**
A single conversion costs approximately $0.01 (start fee + one page at FREE tier). Batch runs are more efficient — $0.05 for 10 pages, $0.25 for 50 pages on the free tier. Paid plans offer lower per-page rates (see pricing table above).

**Why is my PDF missing fonts or background colors?**
If fonts are missing, the web page may use custom web fonts that require the full page to load. Try setting `waitForTimeout: 2000` to give fonts time to download. If background colors or images are missing, make sure `printBackground: true` is set.

**Why are some pages blank or showing an error?**
Some sites block headless browsers or require authentication. If a page consistently fails, it may have bot protection. For pages with slow JavaScript rendering, try adding a `waitForSelector` targeting an element that appears after the content loads, or increase `waitForTimeout`.

**Can I convert password-protected pages?**
No — the actor accesses pages as an anonymous user. Password-protected or login-gated pages will show the login screen in the PDF. To convert authenticated pages, you would need to handle authentication separately before passing a session cookie.

**How do I add headers and footers?**
Set `displayHeaderFooter: true` and provide HTML templates in `headerTemplate` and `footerTemplate`. Use CSS class `.pageNumber` for the current page number and `.totalPages` for total pages. Example footer: `<div style="font-size:8px;text-align:center;width:100%">Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>`

### Other document and web tools

- [HTML to Markdown Converter](https://apify.com/automation-lab) — convert web pages to clean Markdown text
- [Broken Link Checker](https://apify.com/automation-lab/broken-link-checker) — find and report all broken links on your site
- [Canonical URL Checker](https://apify.com/automation-lab/canonical-url-checker) — validate canonical URLs across a site
- [Accessibility Checker](https://apify.com/automation-lab/accessibility-checker) — check WCAG compliance for web pages
- [Color Contrast Checker](https://apify.com/automation-lab/color-contrast-checker) — validate WCAG 2.1 color contrast ratios
- [Bulk Image Optimizer](https://apify.com/automation-lab/bulk-image-optimizer) — compress and convert images in bulk

# Actor input Schema

## `inputType` (type: `string`):

Select what to convert: raw HTML string, a single URL, or a list of URLs.

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

Paste the HTML content to convert to PDF. Used when Input type is 'HTML string'.

## `url` (type: `string`):

URL of the web page to convert to PDF. Used when Input type is 'Single URL'.

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

List of web page URLs to convert to PDF. Used when Input type is 'List of URLs'. Each URL becomes a separate PDF.

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

Paper size for the PDF output.

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

Enable landscape (horizontal) orientation. Default is portrait (vertical).

## `marginTop` (type: `string`):

Top margin of the PDF page. Use CSS units: px, mm, cm, in (e.g. '10mm', '1cm', '0.5in').

## `marginBottom` (type: `string`):

Bottom margin of the PDF page. Use CSS units: px, mm, cm, in.

## `marginLeft` (type: `string`):

Left margin of the PDF page. Use CSS units: px, mm, cm, in.

## `marginRight` (type: `string`):

Right margin of the PDF page. Use CSS units: px, mm, cm, in.

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

Include background colors and images in the PDF. Disable for plain text output.

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

Scale factor for the web page rendering. 1 = 100% (default), 0.5 = 50%, 2 = 200%.

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

HTML template for page header. Use CSS classes: .pageNumber (current page), .totalPages (total pages), .date, .title, .url. Leave empty for no header.

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

HTML template for page footer. Use CSS classes: .pageNumber, .totalPages, .date, .title, .url. Leave empty for no footer.

## `displayHeaderFooter` (type: `boolean`):

Show header and footer templates. Must be enabled for headerTemplate or footerTemplate to appear.

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

CSS selector to wait for before generating PDF. Useful for pages that load content dynamically. Leave empty to generate immediately.

## `waitForTimeout` (type: `integer`):

Additional time to wait (milliseconds) after page load before generating PDF. Useful for JavaScript-heavy pages.

## `outputFileName` (type: `string`):

Prefix for the PDF filename stored in key-value store. Files are named {prefix}-{index}.pdf or {prefix}.pdf for single items.

## `fullPage` (type: `boolean`):

Set PDF height to full scrollable page height instead of fixed page format size.

## Actor input object example

```json
{
  "inputType": "url",
  "html": "<h1>Hello, World!</h1><p>This is a PDF generated from HTML.</p>",
  "url": "https://apify.com",
  "urls": [
    "https://apify.com",
    "https://apify.com/store"
  ],
  "pageFormat": "A4",
  "landscape": false,
  "marginTop": "10mm",
  "marginBottom": "10mm",
  "marginLeft": "10mm",
  "marginRight": "10mm",
  "printBackground": true,
  "scale": 1,
  "headerTemplate": "",
  "footerTemplate": "",
  "displayHeaderFooter": false,
  "waitForSelector": "",
  "waitForTimeout": 0,
  "outputFileName": "output",
  "fullPage": false
}
```

# Actor output Schema

## `overview` (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 = {
    "inputType": "url",
    "html": "<h1>Hello, World!</h1><p>This is a PDF generated from HTML.</p>",
    "url": "https://apify.com",
    "urls": [
        "https://apify.com",
        "https://apify.com/store"
    ],
    "pageFormat": "A4",
    "marginTop": "10mm",
    "marginBottom": "10mm",
    "marginLeft": "10mm",
    "marginRight": "10mm",
    "outputFileName": "output"
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation-lab/html-to-pdf-converter").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 = {
    "inputType": "url",
    "html": "<h1>Hello, World!</h1><p>This is a PDF generated from HTML.</p>",
    "url": "https://apify.com",
    "urls": [
        "https://apify.com",
        "https://apify.com/store",
    ],
    "pageFormat": "A4",
    "marginTop": "10mm",
    "marginBottom": "10mm",
    "marginLeft": "10mm",
    "marginRight": "10mm",
    "outputFileName": "output",
}

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

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

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

```

## CLI example

```bash
echo '{
  "inputType": "url",
  "html": "<h1>Hello, World!</h1><p>This is a PDF generated from HTML.</p>",
  "url": "https://apify.com",
  "urls": [
    "https://apify.com",
    "https://apify.com/store"
  ],
  "pageFormat": "A4",
  "marginTop": "10mm",
  "marginBottom": "10mm",
  "marginLeft": "10mm",
  "marginRight": "10mm",
  "outputFileName": "output"
}' |
apify call automation-lab/html-to-pdf-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=automation-lab/html-to-pdf-converter",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "HTML to PDF Converter",
        "description": "Convert HTML content or web pages to PDF documents. Supports raw HTML strings, single URLs, and bulk URL lists. Full control over page size, margins, orientation, headers, and footers.",
        "version": "0.1",
        "x-build-id": "kqdn0nTqx4BhPQBAu"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/automation-lab~html-to-pdf-converter/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-automation-lab-html-to-pdf-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/automation-lab~html-to-pdf-converter/runs": {
            "post": {
                "operationId": "runs-sync-automation-lab-html-to-pdf-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/automation-lab~html-to-pdf-converter/run-sync": {
            "post": {
                "operationId": "run-sync-automation-lab-html-to-pdf-converter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "inputType": {
                        "title": "📥 Input type",
                        "enum": [
                            "html",
                            "url",
                            "urls"
                        ],
                        "type": "string",
                        "description": "Select what to convert: raw HTML string, a single URL, or a list of URLs.",
                        "default": "url"
                    },
                    "html": {
                        "title": "HTML content",
                        "type": "string",
                        "description": "Paste the HTML content to convert to PDF. Used when Input type is 'HTML string'."
                    },
                    "url": {
                        "title": "Page URL",
                        "type": "string",
                        "description": "URL of the web page to convert to PDF. Used when Input type is 'Single URL'."
                    },
                    "urls": {
                        "title": "List of URLs",
                        "type": "array",
                        "description": "List of web page URLs to convert to PDF. Used when Input type is 'List of URLs'. Each URL becomes a separate PDF.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "pageFormat": {
                        "title": "📐 Page format",
                        "enum": [
                            "A4",
                            "A3",
                            "A5",
                            "Letter",
                            "Legal",
                            "Tabloid"
                        ],
                        "type": "string",
                        "description": "Paper size for the PDF output.",
                        "default": "A4"
                    },
                    "landscape": {
                        "title": "Landscape orientation",
                        "type": "boolean",
                        "description": "Enable landscape (horizontal) orientation. Default is portrait (vertical).",
                        "default": false
                    },
                    "marginTop": {
                        "title": "Margin top",
                        "type": "string",
                        "description": "Top margin of the PDF page. Use CSS units: px, mm, cm, in (e.g. '10mm', '1cm', '0.5in').",
                        "default": "10mm"
                    },
                    "marginBottom": {
                        "title": "Margin bottom",
                        "type": "string",
                        "description": "Bottom margin of the PDF page. Use CSS units: px, mm, cm, in.",
                        "default": "10mm"
                    },
                    "marginLeft": {
                        "title": "Margin left",
                        "type": "string",
                        "description": "Left margin of the PDF page. Use CSS units: px, mm, cm, in.",
                        "default": "10mm"
                    },
                    "marginRight": {
                        "title": "Margin right",
                        "type": "string",
                        "description": "Right margin of the PDF page. Use CSS units: px, mm, cm, in.",
                        "default": "10mm"
                    },
                    "printBackground": {
                        "title": "Print background",
                        "type": "boolean",
                        "description": "Include background colors and images in the PDF. Disable for plain text output.",
                        "default": true
                    },
                    "scale": {
                        "title": "Scale",
                        "minimum": 0.1,
                        "maximum": 2,
                        "type": "number",
                        "description": "Scale factor for the web page rendering. 1 = 100% (default), 0.5 = 50%, 2 = 200%.",
                        "default": 1
                    },
                    "headerTemplate": {
                        "title": "📝 Header HTML",
                        "type": "string",
                        "description": "HTML template for page header. Use CSS classes: .pageNumber (current page), .totalPages (total pages), .date, .title, .url. Leave empty for no header.",
                        "default": ""
                    },
                    "footerTemplate": {
                        "title": "Footer HTML",
                        "type": "string",
                        "description": "HTML template for page footer. Use CSS classes: .pageNumber, .totalPages, .date, .title, .url. Leave empty for no footer.",
                        "default": ""
                    },
                    "displayHeaderFooter": {
                        "title": "Display header/footer",
                        "type": "boolean",
                        "description": "Show header and footer templates. Must be enabled for headerTemplate or footerTemplate to appear.",
                        "default": false
                    },
                    "waitForSelector": {
                        "title": "⏳ Wait for element",
                        "type": "string",
                        "description": "CSS selector to wait for before generating PDF. Useful for pages that load content dynamically. Leave empty to generate immediately.",
                        "default": ""
                    },
                    "waitForTimeout": {
                        "title": "Wait timeout (ms)",
                        "minimum": 0,
                        "maximum": 30000,
                        "type": "integer",
                        "description": "Additional time to wait (milliseconds) after page load before generating PDF. Useful for JavaScript-heavy pages.",
                        "default": 0
                    },
                    "outputFileName": {
                        "title": "Output filename prefix",
                        "type": "string",
                        "description": "Prefix for the PDF filename stored in key-value store. Files are named {prefix}-{index}.pdf or {prefix}.pdf for single items.",
                        "default": "output"
                    },
                    "fullPage": {
                        "title": "Full page height",
                        "type": "boolean",
                        "description": "Set PDF height to full scrollable page height instead of fixed page format size.",
                        "default": false
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
