# HTML to PDF Converter - Web Pages & Raw HTML, Bulk (`propped_cloak/html-to-pdf`) Actor

Convert web pages or raw HTML (invoices, reports) to PDF in bulk: A4, Letter and more, margins, landscape, page numbers, backgrounds, cookie banners hidden. $2 per 1,000 PDFs.

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

## Pricing

from $1.60 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Converter - Web Pages & Raw HTML, Bulk

Turn **web pages or your own HTML** into clean PDF files, in bulk: invoices, reports, certificates, articles, documentation. Choose the **paper size, margins, orientation and page numbers**; backgrounds are kept and cookie banners are hidden. Every PDF gets a download link.

- **URLs or raw HTML.** Print a list of pages, or paste an HTML document (an invoice template, a generated report) and get it back as a PDF.
- **Print-quality layout.** Real Chromium rendering, A4, Letter, Legal, A3, A5 or Tabloid, landscape, custom margins, `page / total` numbers, print or screen CSS.
- **Clean documents.** Cookie banners and consent walls are hidden, ads and trackers are blocked.
- **Cheap.** **$2 per 1,000 PDFs**, where other HTML to PDF Actors charge $6 to $10.
- **No result, no charge.** Pages that fail to load, invalid URLs and internal addresses are free.

### What can I use it for?

- **Invoices, quotes and certificates:** generate a PDF from your HTML template through the API, from Make, Zapier or n8n.
- **Archiving and compliance:** keep dated PDF copies of web pages, terms of service or competitor offers.
- **Reports and documentation:** turn dashboards, articles or docs pages into shareable PDFs.
- **Offline reading:** save long articles as PDF for your e-reader.

### Input

```json
{
    "urls": ["https://www.iana.org/help/example-domains", "https://en.wikipedia.org/wiki/PDF"],
    "html": "<h1>Invoice #2026-001</h1><p>Web audit: 120 EUR</p>",
    "format": "A4",
    "landscape": false,
    "margin": "10mm",
    "pageNumbers": true
}
```

Use `urls`, `html` or both: each URL and the HTML document give one PDF each.

### Output

One row per document, and the PDF files in the run's key-value store:

| Field | Meaning |
|---|---|
| `pdfUrl` | Download link of the PDF (signed: opens without an Apify login) |
| `url` / `source` | The page printed, or `html` for your raw HTML |
| `title` | Title of the page |
| `pages` | Number of pages of the PDF |
| `bytes` | File size |
| `format`, `landscape` | Paper settings used |
| `loadTimedOut` | `true` when the page kept loading: it was printed after 20 more seconds |
| `error` | Why a document could not be created, or why it was not charged |

### Pricing

**$0.002 per PDF created ($2 per 1,000 PDFs)** plus Apify's small run-start fee. No subscription, lower prices on higher Apify plans. Invalid URLs, pages that fail to load and internal addresses are free. Error pages (HTTP 400 and above) and empty pages left by a bot protection are free too: their PDF is still saved.

### Security

Raw HTML is rendered in an isolated browser. Every request it makes (images, scripts, styles) can only reach public internet addresses: internal networks, `localhost`, cloud metadata addresses and `file:` URLs are refused. JavaScript can be turned off with the "Run JavaScript" option.

### Use it from AI agents (MCP)

Add `html-to-pdf` to the [Apify MCP server](https://mcp.apify.com) in your MCP client (Claude, Cursor, VS Code...).

### Integrations

Apify API, schedules, webhooks, Make, Zapier, n8n. Export the results table as JSON, CSV or Excel; the PDFs stay in the run's key-value store for your Apify plan's data retention period.

### Related tools

Same developer, same pay-per-result pricing, outputs that chain together:

- [Website Screenshot](https://apify.com/propped_cloak/website-screenshot): full-page, mobile or dark-mode screenshots of websites.
- [PDF, Word, Excel & PowerPoint to Markdown for RAG](https://apify.com/propped_cloak/document-to-markdown): PDF, Word, Excel and PowerPoint files to clean Markdown for LLMs.
- [Web Page to Markdown for LLM & RAG](https://apify.com/propped_cloak/web-page-to-markdown): clean Markdown of web pages for LLMs and RAG.

### FAQ

**Need an image instead of a PDF?** Use [Website Screenshot](https://apify.com/propped_cloak/website-screenshot).

**Something wrong or missing?** Open an issue on the Issues tab.

# Actor input Schema

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

URLs to print to PDF, one per line. Duplicates are removed. Leave empty if you only convert raw HTML.

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

Optional. A full HTML document (invoice, report, certificate...) converted to one PDF. Images and styles can be loaded from public URLs. Up to 5 MB.

## `format` (type: `string`):

Paper size.

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

Wide pages instead of tall ones.

## `margin` (type: `string`):

Same margin on the 4 sides, with a unit: 10mm, 1cm, 0.5in or 20px.

## `pageNumbers` (type: `boolean`):

Adds "page / total" at the bottom of each page.

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

Keep background colors and images, as on screen.

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

"print" uses the site's print styles (usually cleaner). "screen" keeps the on-screen look.

## `scale` (type: `string`):

Zoom of the content, from 0.1 to 2.

## `hideCookieBanners` (type: `boolean`):

Hides consent banners and walls before printing. Nothing is accepted or refused.

## `blockAds` (type: `boolean`):

Faster loading and cleaner documents.

## `waitUntil` (type: `string`):

When the page is considered ready. Use networkidle for pages that load their content late.

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

Wait this long after loading, for animations or late content.

## `javascript` (type: `boolean`):

Turn off to print the HTML exactly as written, without running its scripts.

## Actor input object example

```json
{
  "urls": [
    "https://www.iana.org/help/example-domains",
    "https://en.wikipedia.org/wiki/PDF"
  ],
  "format": "A4",
  "landscape": false,
  "margin": "10mm",
  "pageNumbers": false,
  "printBackground": true,
  "media": "print",
  "scale": "1",
  "hideCookieBanners": true,
  "blockAds": true,
  "waitUntil": "load",
  "delayMs": 300,
  "javascript": true
}
```

# Actor output Schema

## `results` (type: `string`):

One row per document: download link of the PDF, source page or raw HTML, title, number of pages, size and format.

# 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 = {
    "urls": [
        "https://www.iana.org/help/example-domains",
        "https://en.wikipedia.org/wiki/PDF"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("propped_cloak/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 = { "urls": [
        "https://www.iana.org/help/example-domains",
        "https://en.wikipedia.org/wiki/PDF",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("propped_cloak/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 '{
  "urls": [
    "https://www.iana.org/help/example-domains",
    "https://en.wikipedia.org/wiki/PDF"
  ]
}' |
apify call propped_cloak/html-to-pdf --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,propped_cloak/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/KghXOXzYjotcVWqFS/builds/CicMrKVcgYahgT3J7/openapi.json
