How to Generate PDFs with n8n
Generate PDFs in n8n by preparing HTML, rendering it with Gotenberg or PDFMonkey, and routing the returned PDF binary to its destination.
To generate a PDF in n8n, prepare the document’s data as HTML, send that HTML to a renderer, then pass the returned PDF binary to storage, email, an API response, or another workflow step. n8n orchestrates the process; the renderer does the HTML-to-PDF conversion.
For a self-hosted renderer, use Gotenberg over HTTP. For a managed document service with an n8n integration, PDFMonkey is another option. This guide shows the workflow shape, input and output handling, operational choices, and common failure fixes.
1. Choose a rendering approach
| Approach | Fits when | Workflow interface |
|---|---|---|
| Gotenberg | You can run a renderer reachable by n8n and want to send HTML directly. | Send an HTML file in an HTTP request and receive a PDF binary. |
| PDFMonkey | A managed service and template based workflow fit your needs. | Use its n8n integration for document operations or its HTML-to-PDF API route. |
The n8n Gotenberg template demonstrates creating an index.html binary from an HTML string, submitting it to Gotenberg, and returning the PDF as binary data. It also demonstrates invoking the rendering workflow as a reusable sub-workflow. You need a running Gotenberg service that n8n can reach. Check the current n8n workflow template and Gotenberg conversion documentation for deployment and endpoint details; those specifics can change.
PDFMonkey documents an n8n integration for generating, retrieving, downloading, and deleting documents. Its guide covers node version 1.0.0 and later and was updated on 2026-10-01. For complete HTML supplied in the payload, its HTML-to-PDF guide describes a Code Template that passes through the HTML; the document structure and styles belong in that HTML, while the template settings control page size and margins. See the PDFMonkey n8n integration guide and HTML-to-PDF guide.
2. Prepare the workflow input and HTML
Decide what the workflow accepts before adding the renderer. A reusable input contract can include a record identifier, the fields needed for the document, and an output filename. Keep document data separate from its HTML layout where practical. Escape dynamic values before inserting them into markup; untrusted content must not be allowed to introduce arbitrary HTML or scripts.
A typical workflow is:
- Trigger or source data, such as a form submission or another workflow.
- Shape and validate the fields for the document.
- Build a complete HTML document with its styles and dynamic content.
- Convert the HTML string to a binary file named
index.htmlfor Gotenberg, or map the content into the PDFMonkey integration/API input. - Render the PDF.
- Route the returned binary to the intended destination.
For repeat use, put the render steps in a sub-workflow with an explicit input contract and a predictable output binary property. The n8n template uses this reusable sub-workflow pattern.
3. Generate a PDF with Gotenberg
The important data handoff is HTML text to an HTML file binary, then an HTTP request to a reachable Gotenberg service, then a PDF binary response. The exact node fields and endpoint depend on the current Gotenberg deployment and n8n node version, so use the official template as the reference for those settings.
- Build the HTML string from the workflow data.
- Use n8n’s binary conversion/file node to create a file named
index.htmlfrom that string. Confirm the binary property name that the next node will use. - Add an HTTP Request node configured for the Gotenberg HTML-to-PDF route for your deployment. Attach the HTML binary as the file input expected by that route.
- Configure the request to handle the response as a file/binary result, not parsed JSON.
- Inspect the output binary property and pass it to the next node.
For local development, the n8n instance and Gotenberg container must share network reachability. In containerized deployments, a service name on the shared Docker network is often used in place of localhost; verify this in your own network setup. The cited n8n template includes a Docker Compose approach, but consult current Gotenberg documentation rather than treating a copied Compose file or URL as universal.
4. Use PDFMonkey from n8n
Use the documented PDFMonkey integration when you want its template-oriented document flow. Configure the integration’s credentials, select the document operation, map workflow data to the template fields, and route the generated or downloaded file output onward. Consult the current integration guide for the supported operations and node configuration.
If your workflow already produces a complete HTML document, PDFMonkey’s HTML-to-PDF documentation describes a Code Template that outputs supplied htmlContent. Include a complete HTML document with its styles and content, then configure page size and margins in the template settings. Confirm current input field names and integration behavior in the documentation before deploying, since node and API details are versioned.
5. Route the PDF binary to its destination
A PDF is generally returned from the renderer as binary file data. The next node must use the actual binary property produced by the render step. Common destinations include:
- File storage: configure the storage node to consume the PDF binary property and use the workflow’s filename.
- Email: map the binary property as an attachment and set the recipient and message separately.
- Another workflow: define the binary output as part of the sub-workflow contract and have the caller consume it.
- API response: configure the workflow’s response step to return the binary file with an appropriate content type and filename.
Use a filename that is safe for the destination and stable enough to identify the document. If a workflow can process multiple items, ensure each item’s binary output and filename stay associated with the correct input record.
6. Configure for reliability, volume, and storage
Renderer reachability and timeouts
n8n must be able to reach the renderer from the environment where the workflow executes. Check DNS, container networking, firewall rules, and the configured HTTP destination. Rendering time depends on the document and environment; the reviewed sources provide no general speed benchmark. Set request timeouts to suit your workload and handle failures explicitly rather than assuming every render completes.
Large binary files
PDF workflows can retain sizable binary data in executions. For a basic workflow producing one PDF, external binary storage is not a prerequisite. For higher volume or larger files, review n8n’s current binary data storage and retention settings. n8n documents external S3 storage for self-hosted Enterprise deployments and says Cloud Enterprise customers should contact n8n. The documentation says AWS S3 is officially supported; other S3-compatible services are not officially supported. When using external storage, configure a bucket lifecycle policy if old binary data should be deleted, because pruning is delegated to S3 in that mode. See n8n’s external binary storage documentation and verify current plan eligibility, settings, and retention requirements.
Cost and operational ownership
The sources do not establish current Gotenberg hosting costs, PDFMonkey pricing, render benchmarks, or data retention terms. With Gotenberg, account for operating a reachable renderer and its infrastructure. With a managed service, review the provider’s current plan, terms, and data controls before sending document data. Also account for n8n execution and binary retention in your own deployment.
7. Troubleshoot common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| Connection refused, DNS failure, or timeout | n8n cannot reach the Gotenberg address, or the renderer is unavailable. | Check that the service is running, the hostname resolves from n8n’s execution environment, the network is shared/configured, and the endpoint matches the current Gotenberg docs. |
| Renderer says the HTML file is missing | The request did not attach the expected binary property or filename. | Inspect the conversion node output, verify its binary property name, and confirm the HTTP node attaches that property under the form field expected by the route. |
| HTTP request succeeds but output is not a usable PDF | The response is being handled as text/JSON, or an error response is being mistaken for a file. | Set the response format to file/binary and inspect the response status and headers when the result is unexpected. |
| PDF is blank or missing dynamic values | The HTML was empty, fields were mapped incorrectly, or the template expects different data keys. | Inspect the exact HTML and mapped item entering the renderer; verify the integration’s current template input names. |
| Styles or images do not appear | Assets referenced by the HTML may not be reachable from the renderer, or styles are absent from the supplied document. | Use styles included in the HTML or reachable asset URLs, and confirm the renderer can access any external resources. |
| Workflow becomes large or slow as PDFs accumulate | Binary data and execution history may be retained longer or in greater volume than expected. | Review n8n execution retention, binary storage mode, plan eligibility, and any external bucket lifecycle configuration. |
| PDFMonkey node options differ from a tutorial | The integration guide is versioned and node behavior can change. | Check the current integration guide and installed node version; the cited guide covers 1.0.0+. |
8. Capture a web page as a PDF instead
If the source is a live web page rather than your own prepared document HTML, a screenshot service can return a PDF from a URL. ScreenshotNeo is a website screenshot API and MCP server for developers. Its API accepts a URL and returns an image or PDF; see the API documentation.
Or skip the browser setup
Call the API from an n8n HTTP Request node or another workflow step. This cURL example shows the request shape; replace the key and target URL:
curl -G "https://api.screenshotneo.com/v1/shot" \
-d access_key=YOUR_API_KEY \
--data-urlencode url=https://stripe.com \
-d format=pdf \
-o page.pdf
For Python:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com", "format": "pdf"},
timeout=90,
)
open("page.pdf", "wb").write(r.content)
For Node.js:
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://stripe.com',
format: 'pdf'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`ScreenshotNeo request failed: ${res.status}`);
await Bun.write('page.pdf', new Uint8Array(await res.arrayBuffer()));
With an n8n HTTP Request node, pass the URL and access key as query parameters, request a file response, and map the returned binary into the following storage or email node. Keep the key in n8n credentials or another protected secret store rather than embedding it in a public workflow export.
- Cookie banners are accepted and removed before capture, along with known consent platforms, newsletter popups, and chat widgets; each step can be turned off.
- Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; the response identifies the page verdict and billing status in headers.
- An MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs.
- The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000.
Sign up free for 1,000 screenshots a month, no card required.
FAQ
Does n8n render the PDF itself?
In the cited Gotenberg pattern, n8n orchestrates the steps and Gotenberg performs the HTML-to-PDF rendering.
Do I need external binary storage to generate a PDF?
No. External binary storage is a scaling and retention choice for eligible n8n deployments, not a requirement for the basic render flow.
Can I reuse one PDF workflow for multiple automations?
Yes. Put the rendering steps in a sub-workflow and define its accepted HTML/data input and returned binary output clearly.
Should I use a renderer or a screenshot API?
Use an HTML-to-PDF renderer when generating a designed document from workflow data. Use a screenshot API when the input is a web page URL you want captured as a PDF.


