HTML to PDF Converter avatar

HTML to PDF Converter

Pricing

Pay per event

Go to Apify Store
HTML to PDF Converter

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

Pay per event

Rating

0.0

(0)

Developer

Stas Persiianenko

Stas Persiianenko

Maintained by Community

Actor stats

0

Bookmarked

3

Total users

1

Monthly active users

3 days ago

Last modified

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 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 fieldDescription
pdfKeyFilename of the PDF in the key-value store (e.g., output.pdf)
pdfUrlDirect download URL for the PDF
fileSizeKbPDF file size in kilobytes
sourceThe original URL or "(HTML string)"
successWhether the conversion succeeded
errorError 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.

PlanPrice 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 casePagesEstimated cost
Single invoice or report1~$0.01
Weekly batch of 10 pages10~$0.055
Daily batch of 50 pages50~$0.255
Monthly archive of 200 pages200~$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 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

{
"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",
"outputFileName": "report"
}

Input parameters

ParameterTypeDefaultDescription
inputTypestringurlWhat to convert: html, url, or urls
htmlstringRaw HTML content to convert (when inputType is html)
urlstringURL to convert (when inputType is url)
urlsarrayList of URLs to convert (when inputType is urls)
pageFormatstringA4Page size: A4, A3, A5, Letter, Legal, Tabloid
landscapebooleanfalseUse landscape orientation
marginTopstring10mmTop margin (e.g., 10mm, 1cm, 0.5in)
marginBottomstring10mmBottom margin
marginLeftstring10mmLeft margin
marginRightstring10mmRight margin
printBackgroundbooleantrueInclude background colors and images
scalenumber1Page scale factor (0.1–2.0)
displayHeaderFooterbooleanfalseShow header/footer templates
headerTemplatestringHTML template for page header
footerTemplatestringHTML template for page footer
waitForSelectorstringCSS selector to wait for before PDF generation
waitForTimeoutinteger0Extra wait time (ms) before PDF generation
outputFileNamestringoutputPrefix for PDF filenames
fullPagebooleanfalseCapture 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,
"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

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 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

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.

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