Skip to main content

Generate PDF invoices with CustomJS API

Workflow preview

Workflow preview
100%
Generate PDF invoices with CustomJS API preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

n8n Workflow: Invoice PDF Generator This n8n workflow captures invoice data and generates a PDF invoice, ready to be sent or saved. It uses a webhook to trigger the pro...

Best for

  • Invoice Processing automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

@custom-js/n8n-nodes-pdf-toolkit.html2pdf, n8n-nodes-base.code, n8n-nodes-base.set, n8n-nodes-base.webhook, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by CustomJS.

Original n8n.io source

1.1 Workflow description

Title
Generate PDF invoices with CustomJS API
Workflow name
Generate PDF invoices with CustomJS API

n8n Workflow: Invoice PDF Generator

This n8n workflow captures invoice data and generates a PDF invoice, ready to be sent or saved. It uses a webhook to trigger the process, preprocesses the invoice data, and converts it to a PDF using HTML and custom styling.

@custom-js/n8n-nodes-pdf-toolkit

Features:

  • Webhook Trigger: Receives incoming data, including invoice details.
  • Preprocessing: Transforms the invoice data into HTML format.
  • HTML to PDF Conversion: Converts the preprocessed HTML into a styled PDF document.
  • Response: Sends the generated PDF back to the webhook response.

Notice

Community nodes can only be installed on self-hosted instances of n8n.

Requirements

  • Self-hosted n8n instance
  • A CustomJS API key for website screenshots.
  • Invoice data for PDF generation

Workflow Steps:

  1. Webhook Trigger:

    • Accepts incoming data (e.g., invoice number, recipient details, itemized list).
    • This data is passed to the next node for processing.
  2. Set Data Node:

    • Configures initial values for the invoice, including the recipient, sender, invoice number, and the items on the invoice.
    • The invoice details include information like description, unit price, and quantity.
  3. Preprocess Node:

    • Processes the raw data to format it correctly for HTML. This includes splitting addresses and converting the items into an HTML table format.
  4. HTML to PDF Conversion:

    • Converts the generated HTML into a PDF document. The HTML includes a header, a detailed invoice table, and a footer with contact information.
  5. Respond to Webhook:

    • Returns the generated PDF as a response to the initial webhook request.

Setup Guide:

1. Configure CustomJS API

  • Sign up at CustomJS.
  • Retrieve your API key from the profile page.
  • Add your API key as n8n credentials.

2. Design Workflow

  1. Create a Webhook:

    • Set up a webhook to trigger the workflow when invoice data is received.
  2. Prepare Data:

    • Ensure the incoming request contains fields like "Invoice No", "Bill To", "From", and "Details" (list of items with price and quantity).
  3. Customize the HTML:

    • The HTML template for the invoice includes custom styling to give the invoice a professional look.
  4. Convert to PDF:

    • The HTML to PDF node is configured with the data generated from the preprocessing step to convert the invoice HTML to a PDF format.

Example Invoice Data:

{
  "Invoice No": "1",
  "Bill To": "John Doe\n1234 Elm St, Apt 567\nCity, Country, 12345",
  "From": "ABC Corporation\n789 Business Ave\nCity, Country, 67890",
  "Details": [
    {
      "description": "Web Hosting",
      "price": 150,
      "qty": 2
    },
    {
      "description": "Domain",
      "price": 15,
      "qty": 5
    }
  ],
  "Email": "[email protected]"
}

Result PDF File

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - HTML to PDF

Type / Role
@custom-js/n8n-nodes-pdf-toolkit.html2Pdf - html2Pdf
Config choices
Version 1

Block 2 - Preprocess

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - Set data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 4 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 5 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

3. Summary Table

Workflow Generate PDF invoices with CustomJS API
Complexity intermediate
Nodes 5
Categories Invoice Processing
Author CustomJS
Published 26 Mar 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3333/3333.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Generate PDF invoices with CustomJS API do?

n8n Workflow: Invoice PDF Generator This n8n workflow captures invoice data and generates a PDF invoice, ready to be sent or saved. It uses a webhook to trigger the pro...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Invoice Processing use case.