HTML To PDF for N8N avatar
HTML To PDF for N8N

Pricing

from $10.00 / 1,000 results

Go to Apify Store
HTML To PDF for N8N

HTML To PDF for N8N

Generate accurate PDFs from HTML or URLs using Chromium. Supports CSS, fonts, and backgrounds. Automation-ready and perfect for n8n workflows, reports, invoices, and contracts.

Pricing

from $10.00 / 1,000 results

Rating

0.0

(0)

Developer

Gavin Campbell

Gavin Campbell

Maintained by Community

Actor stats

1

Bookmarked

4

Total users

2

Monthly active users

8 days ago

Last modified

Share

HTML to PDF Converter for n8n & API

This Apify Actor is a high-performance microservice that converts HTML or URLs into PDF files. It is optimized for automation workflows (n8n, Make, Zapier) by returning a direct download link to the generated PDF.

🚀 Quick Start for n8n

You can easily use this Actor within n8n to generate invoices, reports, or web captures.

Step 1: Trigger the Actor

Use the Apify node in n8n:

  • Resource: Actor
  • Operation: Run
  • Actor: html-to-pdf (or copy the Actor ID if running a custom build)
  • Input: JSON (see examples below)

Step 2: Download the PDF

The Actor outputs a dataset containing a pdfUrl field. Use an HTTP Request node to download the file:

  • Method: GET
  • URL: {{ $json["pdfUrl"] }}
  • Authentication: Generic Credential Type -> Query Auth
    • Name: token
    • Value: (Your Apify API Token)

📡 API Usage & Input Examples

When calling this Actor via the Apify API (POST /acts/[ACTOR_ID]/run-sync-get-dataset-items), pass these JSON bodies:

Option A: Convert a Website URL

Best for capturing reports, articles, or dashboards.

{
"url": "https://admindone.com",
"pdfFormat": "A4",
"landscape": true,
"printBackground": true,
"waitUntil": "networkidle",
"fileName": "admindone_report.pdf"
}

Option B: Convert Raw HTML (e.g., Invoices)

Best for generating dynamic documents from your own data.

{
"html": "<html><body><h1>Invoice #99</h1><p>Total: $100.00</p></body></html>",
"pdfFormat": "Letter",
"marginTop": "20mm",
"marginRight": "20mm",
"marginBottom": "20mm",
"marginLeft": "20mm",
"allowExternalRequests": false
}

📦 Output Format

The Actor produces a structured JSON output in the default Dataset.

Example Response:

[
{
"inputType": "url",
"target": "https://admindone.com",
"pdfUrl": "https://api.apify.com/v2/key-value-stores/mI5f8.../records/OUTPUT.pdf",
"fileName": "document.pdf",
"pdfBytes": 45032,
"timing": {
"totalMs": 2300,
"renderMs": 1500,
"pdfMs": 600
},
"optionsUsed": { ... },
"timestamp": "2023-10-27T10:00:00.000Z"
}
]
  • pdfUrl: The direct link to your generated PDF. (Note: Requires your API token to access).
  • pdfBytes: File size in bytes.

⚙️ Configuration Options

OptionTypeDefaultDescription
htmlString-Raw HTML string to render.
urlString-Public URL to render.
pdfFormatStringA4Page size (Letter, A4, A3, etc.)
landscapeBooleanfalseLandscape orientation.
printBackgroundBooleantrueInclude background graphics/colors.
scaleNumber1Zoom level (0.1 to 2).
marginTopString10mmTop margin (units: mm, cm, px).
waitUntilStringnetworkidleWhen to consider navigation finished (load, domcontentloaded, networkidle).
allowExternalRequestsBooleanfalse(HTML only) Allow loading images/scripts from the web.

🛠 Troubleshooting

  • Blank PDF? If the site uses heavy JavaScript (React/Vue), change waitUntil to networkidle and increase timeoutSecs.
  • Images missing in HTML? If you use <img src="https://...">, you must set allowExternalRequests: true.
  • Access Denied on pdfUrl? Ensure you append ?token=YOUR_APIFY_TOKEN to the URL when fetching it outside of the Apify Console.