DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
Automation

How to Convert HTML to PDF in n8n Without a Third-Party API

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a self-hosted Gotenberg service beside n8n. Build your HTML in the workflow, turn it into binary data named index.html, send that file as multipart form data to Gotenberg’s Chromium endpoint, and pass the returned PDF binary to storage, email, or a webhook. This avoids sending the document to a hosted PDF-conversion vendor, while still using Gotenberg’s local HTTP API.

If “without an API” means no HTTP request at all, the documented n8n pattern does not meet that definition. The reliable, documented approach is an API call to a renderer you operate in your own Docker network.

What you are building

The workflow has four logical parts:

  1. Generate a complete HTML document in n8n.
  2. Convert the string to binary file data with the exact filename index.html.
  3. POST that file to Gotenberg at http://gotenberg:3000/forms/chromium/convert/html.
  4. Use Gotenberg’s PDF response as binary data in the next node.

Gotenberg runs Chromium for HTML rendering. In Docker Compose, containers on the same network can address the service by the name gotenberg. The HTML endpoint returns the generated PDF in the response body, so n8n can continue without writing a shared file to disk.

Run Gotenberg next to n8n

Choose an image that includes Chromium

Gotenberg’s full image includes Chromium, LibreOffice, and PDF engines. Its Chromium-only image supports URL, HTML, and Markdown conversion. The LibreOffice-only image does not support URL, HTML, or Markdown conversion, so it is the wrong choice for this workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Docker Compose example

Add a Gotenberg service to the Compose project that runs your self-hosted n8n instance. A minimal service is:

services:
  gotenberg:
    image: gotenberg/gotenberg:8
    expose:
      - "3000"
  n8n:
    image: n8nio/n8n
    depends_on:
      - gotenberg

The exact n8n service definition, volumes, database, and environment variables depend on your deployment. The important detail is that both services share a Docker network and that n8n can resolve gotenberg. You do not need to publish Gotenberg’s port to the public internet for service-to-service calls.

Do not expose the renderer unnecessarily

Published Docker ports are externally reachable by default. If only n8n needs Gotenberg, omit a public ports mapping and use expose, or bind a published port to localhost when you need host-side testing. Keeping the renderer private reduces the attack surface.

Build the HTML inside n8n

Prepare a complete document

In a Code node, Set node, or upstream application node, create a JSON property named html. Include the document structure and any CSS required for printing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    @page { size: A4; margin: 18mm; }
    body { font-family: Arial, sans-serif; color: #222; }
    h1 { break-after: avoid; }
    .page-break { break-before: page; }
  </style>
</head>
<body>
  <h1>Invoice</h1>
  <p>Generated by n8n.</p>
</body>
</html>

Keep the HTML self-contained where possible. External CSS, images, and fonts must be reachable by the Chromium process, not merely by your browser or the n8n host.

Create binary data named index.html

Gotenberg’s HTML endpoint expects the uploaded document to be named exactly index.html. In n8n, use the node or operation that converts text to a binary file, set the source to your html property, and set the filename to index.html. The binary property can be named data (or another name you choose), but the filename must remain index.html.

Do not assume that a path such as /files/report.html visible inside n8n is visible inside the Gotenberg container. Upload the file in the request instead; that is the documented HTML-conversion pattern.

Rank #2
Sale
CNC Programming Handbook, Third Edition
  • New
  • Mint Condition
  • Dispatch same day for order received before 12 noon
  • Guaranteed packaging
  • No quibbles returns

Configure the HTTP Request node

  1. Add an HTTP Request node after the binary-preparation step.
  2. Set the method to POST.
  3. Use http://gotenberg:3000/forms/chromium/convert/html as the URL when n8n and Gotenberg are peer containers.
  4. Choose multipart form-data and add the binary property containing index.html as the file field expected by the Gotenberg HTML endpoint.
  5. Set the response format to File (binary), not JSON.
  6. Execute the node and inspect the output binary. It should be a PDF that can be passed to a storage, email, or webhook node.

n8n labels can vary between versions. Verify the current HTTP Request node’s binary-field and response-format labels against the n8n version you run. The essential behavior is an authenticated or unauthenticated multipart upload of index.html and a binary response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Send the PDF to the next step

The returned binary can be used directly as:

  • an attachment in an email node;
  • an object uploaded to S3-compatible storage;
  • a file written by a storage node;
  • a webhook response with a PDF content type; or
  • input to another document-processing step.

Give the output a meaningful filename after conversion, such as invoice-{{$json.id}}.pdf. Keep the original HTML and the resulting PDF in separate binary properties if later nodes need both.

Dynamic pages: wait for the right moment

Chromium can capture a page before JavaScript-generated charts, data, or external assets finish rendering. A fixed delay (waitDelay) is easy but can be either too short or needlessly slow. Gotenberg also supports waitForExpression, which waits for a condition in the page and is generally more deliberate.

Use an explicit readiness flag

If you control the HTML, set a flag after your data and charts are ready, for example:

<script>
  renderReport().then(() => {
    window.reportReady = true;
  });
</script>

Configure the renderer to wait for an expression that evaluates to true, using the option names and syntax documented for the Gotenberg version you installed. If you cannot add a readiness signal, use a conservative delay and test under production-like network conditions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Assets, CSS, and page layout

Relative assets

The HTML endpoint can accept optional CSS, images, and fonts referenced by relative paths. Ensure those assets are included in the request as supported by your Gotenberg version, or make them reachable over the network. A URL that works in your laptop browser may fail inside a private container network.

Print-specific CSS

Use @page for paper size and margins, and CSS break properties to control pagination. Test long tables, headings near page bottoms, background colors, SVGs, web fonts, and images. PDF output should be checked at the final paper size; a layout that looks correct in a wide browser viewport can still overflow an A4 page.

URL conversion versus HTML conversion

Gotenberg has a URL endpoint for converting a reachable web address and an HTML endpoint for an uploaded index.html. For HTML generated inside n8n, use the HTML endpoint. The URL endpoint rejects file:// URLs; local HTML should be sent through the HTML or Markdown endpoints instead.

Cloud n8n and hosted alternatives

n8n Cloud cannot automatically resolve the private Docker hostname gotenberg in your local Compose network. You would need a securely reachable renderer, or a hosted conversion service. A November 2025 community announcement from PDFMunk’s founder described a verified HTML-to-PDF community node for n8n Cloud Editions, including HTML/CSS conversion and website screenshots to PDF, with a PDF URL as output. Availability and terms can change, so confirm them in n8n’s current community-node catalog before relying on that route.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is a different data-flow choice: your HTML goes to a hosted service instead of staying within your own deployment. If network control is the reason for avoiding a third-party API, self-hosted Gotenberg is the closer match.

Public Gotenberg demo: useful only for trials

The official installation documentation describes a public demo limited to 2 requests per second per IP and a 5 MB request body. Those are demo-instance limits, not a general limit on a Gotenberg deployment you operate. Do not build production n8n workflows around the public demo.

Troubleshooting

“Connection refused” or DNS errors

Cause: n8n cannot reach the service name or Gotenberg is not running.

Fix: confirm both containers are on the same Compose network, use gotenberg rather than localhost from inside n8n, and inspect container logs and health status.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Gotenberg reports a missing index.html

Cause: the multipart upload has the wrong filename or the binary field is not being sent as a file.

Fix: inspect the binary metadata in n8n and set the filename exactly to index.html. In the HTTP Request node, select the binary property as a multipart file field.

The HTTP Request node shows unreadable PDF bytes

Cause: n8n is treating the response as text or JSON.

Fix: set the response format to File/binary, then verify the output mime type and filename before passing it onward.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Images or fonts are missing

Cause: the renderer cannot resolve the asset URL, the asset is blocked by network policy, or it was not included as an optional asset.

Fix: use reachable absolute URLs or upload supported assets, check container DNS and egress, and test with a minimal document to isolate the failing resource.

Charts are incomplete

Cause: capture occurs before JavaScript finishes.

Fix: add a readiness expression when possible; otherwise increase the delay and verify that all API calls and fonts finish before conversion.

Pages break in unexpected places

Cause: screen-oriented CSS, oversized elements, or untested print dimensions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: add print CSS, define page size and margins, use break rules, and test representative long and short documents.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost decisions

  • Keep traffic internal: service-to-service Docker networking avoids an unnecessary public hop.
  • Control concurrency: large batches can exhaust CPU and memory because each conversion runs a browser workload. Queue or throttle n8n executions according to your host capacity.
  • Make jobs observable: record the input identifier, renderer response, elapsed time, and final binary size so failed documents can be retried safely.
  • Retry selectively: retry transient connection or navigation failures, but fix malformed HTML, missing files, and deterministic layout errors instead of retrying them indefinitely.
  • Validate output: open generated PDFs from real production data, not only a small sample HTML string.

Self-hosting removes a per-document hosted conversion bill, but you still operate the containers and the compute they consume. Capacity, backups, upgrades, and network security remain your responsibility.

Or skip the browser setup

If your real requirement is a screenshot or PDF from a URL rather than rendering an HTML string inside your private n8n network, ScreenshotNeo provides a single-call API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with the result identified by response headers. Its MCP tools let Claude, Cursor, and other MCP clients call take_screenshot, get_page_info, and capture_pdf.

For a URL-to-PDF call, use the API documentation at https://screenshotneo.com/docs/ and adapt the request to your target URL:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo includes 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. It is not a replacement for the self-hosted index.html upload when your HTML must remain inside your network, but it can remove browser and renderer setup for public URLs. Sign up free.

Frequently Asked Questions

Can n8n Cloud call Gotenberg at gotenberg:3000?

No. That hostname is a Docker-network address for containers in the same deployment. n8n Cloud needs a securely reachable renderer or a hosted conversion node.

Does Gotenberg convert a local file path automatically?

No. The documented HTML workflow uploads the document as multipart data, with the filename set to index.html.

Which Gotenberg image supports HTML-to-PDF?

Use the full image or Chromium-only image. The LibreOffice-only image does not support URL, HTML, or Markdown conversion.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What does “without an API” mean in this setup?

It means avoiding a third-party hosted conversion API. n8n still makes an HTTP request to the Gotenberg service you operate.

Quick Recap

SaleBestseller No. 2
CNC Programming Handbook, Third Edition
CNC Programming Handbook, Third Edition
New; Mint Condition; Dispatch same day for order received before 12 noon; Guaranteed packaging
$98.00
Bestseller No. 5

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.