HTML to PDF Converter
Pricing
from $3.00 / 1,000 page converteds
HTML to PDF Converter
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.
Pricing
from $3.00 / 1,000 page converteds
Rating
0.0
(0)
Developer
Automation Lab
Maintained by CommunityActor stats
1
Bookmarked
53
Total users
7
Monthly active users
a day ago
Last modified
Categories
Share
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 a public web page or HTML string into a PDF using a real Chromium browser (via Playwright). It renders JavaScript, CSS, web fonts, and background images before Chromium creates a print-layout snapshot 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 tools that only handle static markup, this actor loads the page in Chromium and offers explicit readiness, selector, and delay controls. PDFs capture the page's print state at conversion time; interactive behavior and animations are not preserved.
Who is it 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
- ✅ Reliable batch conversion — convert up to 20 URLs with isolated browser contexts and bounded concurrency
- ✅ 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 |
durationMs | Time spent processing this item in milliseconds |
errorStage | Failed phase (validation, navigation, selector, render, or storage), otherwise null |
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.
| Apify plan | Price per page |
|---|---|
| Free | $0.00575 |
| Bronze | $0.005 |
| Silver | $0.0039 |
| Gold | $0.003 |
| Platinum | $0.002 |
| Diamond | $0.0014 |
Plus a one-time start fee of $0.005 per run.
Calculated cost examples at Free-tier pricing (not event unit prices)
| 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
- Go to the HTML to PDF Converter page on Apify Store
- Click Try for free
- Choose your Input type: HTML string, Single URL, or List of URLs
- Enter your HTML content or URL(s)
- Set your PDF options: page format, margins, orientation, headers/footers
- Click Start to begin the conversion
- When the run finishes, find your PDFs in the Key-value store tab
- Download directly or use the PDF URL in your workflow
Example: Convert a single web page
{"inputType": "url","url": "https://example.com","pageFormat": "A4","printBackground": true}
Example: Convert raw HTML to PDF with custom margins
{"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
{"inputType": "urls","urls": ["https://example.com/page-1","https://example.com/page-2","https://example.com/page-3"],"pageFormat": "A4","maxConcurrency": 2,"waitUntil": "networkidle","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 | — | Up to 20 public HTTP(S) URLs (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 up to 15 seconds for before PDF generation |
failOnSelectorTimeout | boolean | false | Fail an item when its selector does not appear; otherwise warn and continue |
waitForTimeout | integer | 0 | Extra wait time (ms) after readiness and selector checks |
waitUntil | string | networkidle | Readiness milestone: domcontentloaded, load, or networkidle |
navigationTimeoutSecs | integer | 60 | Per-item navigation/readiness timeout (5–120 seconds) |
maxConcurrency | integer | 2 | Number of isolated batch items processed at once (1–5) |
outputFileName | string | output | Prefix for PDF filenames |
fullPage | boolean | false | Capture full scrollable page height |
Output examples
Each converted page produces one dataset record:
{"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,"durationMs": 2841,"errorStage": null,"error": null}
For batch conversions (inputType: urls), PDFs are named {outputFileName}-001.pdf, {outputFileName}-002.pdf, etc. Dataset rows and filenames always follow input order even when pages run concurrently. Invalid or failed URLs produce diagnostic rows and are not charged as converted pages. Partial-success batches finish successfully; if every item fails, the Actor writes all diagnostic rows and then fails the run.
Tips for best results
- 💡 Start small: Test with a single URL before batch-converting many pages
- 🎨 Background images not showing? Make sure
printBackground: trueis set - ⏳ Dynamic content not loaded? Choose the appropriate
waitUntil, usewaitForSelectorfor a content marker, or addwaitForTimeout(e.g.,2000for 2 seconds). EnablefailOnSelectorTimeoutwhen missing content must fail the item. - 📐 Full-page captures: Set
fullPage: trueto avoid page breaks and get one continuous PDF - 📝 Headers and footers: Set
displayHeaderFooter: trueand provide HTML templates with.pageNumberand.totalPagesCSS classes - 💾 Custom filenames: Use
outputFileNameto set a descriptive prefix for your PDFs - 🔢 Scaling: Use
scale: 0.8to fit more content per page, orscale: 1.2to 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.
API usage
Use the Apify API to run HTML to PDF Converter programmatically from your own code.
Node.js
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
from apify_client import ApifyClientclient = 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().itemsprint('PDF URL:', items[0]['pdfUrl'])
cURL
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).
Add the Apify MCP server to your AI client — this gives you access to all Apify actors, including this one:
Setup for Claude Code
$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:
{"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.
Legality
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 and does not crawl links. URL mode is designed for anonymously accessible public HTTP(S) pages; this Actor does not accept credentials, cookies, or login sessions. Always ensure you have the right to capture the content you're converting.
Data handling, retention, and support
The Actor processes only the HTML and URLs supplied in the run. HTML stays inside the run's browser process; URL mode sends ordinary anonymous browser requests to the selected websites. No AI provider, proxy product, paid content API, credential service, or external database receives the input. The Actor stores PDFs in the run key-value store, conversion diagnostics in the run dataset, and operational messages in run logs. It creates no separate cache or external copy. These storages follow the retention and deletion settings of your Apify account and can be deleted through Apify Console or API controls.
Do not place passwords, session tokens, or other secrets in URLs. For help, use the Issues tab on this Actor's Apify Store page and include a reproducible input with sensitive values removed.
FAQ
How fast does conversion take?
A single page typically converts in 5–20 seconds depending on complexity, rendering time, and network conditions. Batch jobs process up to maxConcurrency pages in isolated browser contexts (default 2, maximum 5), so total time depends on the slowest pages and your readiness settings.
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>
Related Actors
- Markdown ↔ HTML Converter — convert web pages to clean Markdown text and back
- Broken Link Checker — find and report all broken links on your site
- Canonical URL Checker — validate canonical URLs across a site
- Accessibility Checker — check WCAG compliance for web pages
- Color Contrast Checker — validate WCAG 2.1 color contrast ratios
- Bulk Image Optimizer — compress and convert images in bulk
