HTML to PDF Conversion using Gotenberg API - n8n Workflow

Use this efficient n8n workflow template to convert incoming HTML strings into professional, customized PDF documents instantly via a self-hosted Gotenberg service. A key n8n automation for document management.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers who need reliable, self-hosted solutions for automated document generation.
Users requiring a private, high-volume PDF conversion tool integrated into their existing n8n environment.
Technical users looking for advanced n8n templates demonstrating complex binary file handling and external API integration.
Anyone utilizing Docker for their n8n setup and wanting to leverage other containerized services.

Overview

Generating high-quality PDF documents from dynamic HTML content is a common challenge in automation. While many online services exist, they often introduce privacy concerns or scalability issues. This specialized n8n workflow template solves this by integrating directly with a self-hosted Gotenberg service, running securely alongside your n8n instance.

This automation provides a secure and highly customizable method for creating professional reports, invoices, or complex documents. The workflow accepts HTML data and a desired output filename through its initial n8n trigger, handles the file preparation internally, and sends the request to Gotenberg, ensuring efficient and private PDF generation. Mastering this n8n automation means full control over your document pipeline, a critical feature for professional systems.

How it Works

This n8n workflow initiates when manually run or called by an external webhook or trigger, expecting HTML content and a desired file name.


  1. Input Trigger: The workflow starts at the Create PDF from HTML n8n trigger node. This node is configured to expect two essential input fields: html (the content to convert) and file_name (the name of the resulting PDF).

  2. File Preparation: The flow moves to the Create index.html n8n node, which uses the internal convertToFile function. It takes the incoming html string and converts it into a binary file named index.html. This is a necessary step to properly package the HTML for the Gotenberg API.

  3. Gotenberg API Call: The crucial step occurs in the Convert to PDF with Gotenberg n8n node (an HTTP Request n8n node). This node performs a POST request to the Gotenberg service (defaulting to http://gotenberg:3000/forms/chromium/convert/html). It sends the binary file prepared in the previous step using multipart-form-data encoding.

  4. Metadata Customization: Critically, this n8n node also passes customized metadata (such as Author, Title, Creation Date, and Keywords) within the request body. It also sets the output filename dynamically using an expression linking back to the initial input defined in the n8n trigger.

  5. Output: Gotenberg returns the generated PDF document as a binary output, which can then be saved, uploaded to cloud storage, or attached to an email using subsequent n8n nodes.

Installation Guide

To deploy this n8n workflow template successfully, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n environment using the 'New' -> 'Import from JSON' function.

  2. Prerequisite: Set up Gotenberg: This workflow requires a running Gotenberg service. The easiest method is to ensure both n8n and Gotenberg are running in the same Docker network. A typical Docker configuration looks like this:

gotenberg:
image: gotenberg/gotenberg:8
restart: always

  1. Configure the API URL: In the Convert to PDF with Gotenberg n8n node, check the URL. If your Gotenberg service is hosted outside the standard Docker network or on a different port, you must update the url parameter from http://gotenberg:3000/forms/chromium/convert/html to your specific endpoint.

  2. Customize Metadata: Review the 'Body Parameters' in the Convert to PDF with Gotenberg n8n node to adjust PDF metadata like Author and Title to match your needs.

  3. Test: Execute the Create PDF from HTML n8n trigger manually to ensure a PDF is generated correctly.

Node Details

Create PDF from HTML (Execute Workflow Trigger)
Function: Acts as the starting point (n8n trigger) for the workflow, providing sample data for the execution.
Key Configuration: Input data is defined with html content and the desired output file_name.

Create index.html (Convert to File)
Function: Transforms the input HTML string into a storable binary file (index.html). Gotenberg requires the input to be sent as a file, making this n8n node essential for preparation.
Key Configuration: operation: toText, sourceProperty: html, fileName: index.html.

Convert to PDF with Gotenberg (HTTP Request)
Function: Sends the prepared binary HTML file to the self-hosted Gotenberg service for conversion into a PDF document. This is the core action of the entire n8n workflow.
Key Configuration:
URL: http://gotenberg:3000/forms/chromium/convert/html (Must be adjusted if using a remote service).
Content Type: multipart-form-data.
Body Parameters: Includes the binary data input and extensive JSON-formatted PDF metadata for customization.
* Headers: Uses the Gotenberg-Output-Filename header with a dynamic expression to set the final PDF name based on the initial n8n trigger input.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

Innovative builder with a passion for crafting automation solutions that solve real-world challenges. From streamlining workflows to driving efficiency, my work empowers teams and individuals to achieve more with less effort. Experienced in developing scalable tools and strategies that deliver results with n8n, supabase and cline.

Featured*