Generating your first Document with n8n

Ready to generate your first document with n8n and PDFMonkey? Learn to create your first document effortlessly with PDFMonkey's step-by-step guide.

What is n8n?

n8n is a powerful workflow automation platform that allows you to connect different apps and services together. It's an open-source alternative to tools like Zapier, offering both cloud and self-hosted options.

Prerequisites

Before we start, you'll need:

Create an account on PDFMonkey

To create an account, go to the Register page and fill in you email and password.

We do not ask for a password confirmation but you can toggle password hiding by clicking on Show my password.

Once you've filled in your credentials, we will send you an activation email. Click the link in the email to activate your account. You will not be able to sign in until your account is confirmed.

Sign in

Once your account confirmed, fill in your credentials in the Sign in page to get access to your dashboard.

Create your first Template

To create a template, head to the Templates page and click on Create my first Template.

Give a name to your template, select the Code edition mode and select the Base Template named Blank.

It will open the Template Editor, where PDFMonkey's magic happens.

A name is just a name

You can change the name of your Template as often as you want, it will have no impact on your client applications.

Writing your first Template

In the HTML tab, insert the following code:

HTML
<p class="greeting">Hello {{name}}!</p>
<p>Your favorite number is {{favoriteNumber}}.</p>

In the CSS tab, insert the following code:

.greeting {
  color: #6D28D9;
  font-size: 24px;
}

And finally in the Test data tab, insert this:

{
  "name": "Peter Parker",
  "favoriteNumber": 8
}

You can now click on the Save button, and you should see the preview panel on the right update to reflect your changes.

Real PDF preview

The PDF preview you see is actually a 100% accurate version of what the final result will be as it is a real PDF, generated using the same process we use to generate your Documents.

The last step is to make your Template available for generation. To do so, click on the Publish button.

Authoring Templates

Setting up PDFMonkey credentials in n8n

Before using the PDFMonkey node, you need to configure your API credentials:

  1. In your n8n workflow, add a PDFMonkey node

  2. Click on Create New Credentials

  3. Enter your PDFMonkey API key (found in your PDFMonkey dashboard)

  4. Click Save

Creating your first workflow

Let's create a simple workflow that generates a PDF when triggered manually.

Step 1: Add a Manual Trigger

  1. Create a new workflow in n8n

  2. The Manual Trigger node should already be there

  3. This will allow you to test your workflow manually

Step 2: Add the PDFMonkey node

  1. Click the + button to add a new node

  2. Search for PDFMonkey

  3. Select the PDFMonkey node

  4. Choose Generate Document as the operation

Step 3: Configure the Generate Document operation

In the PDFMonkey node configuration:

  1. Select your PDFMonkey credentials (or create them if you haven't)

  2. Set your Template ID from your PDFMonkey Template

  3. Set the Payload Input Method to Key-Value Pairs

  4. Add the following fields:

    • Key: name → Value: Peter Parker

    • Key: favoriteNumber → Value: 8

Payload methods

You can choose between Key-Value Pairs (simple) or JSON (for complex data structures). We'll cover the JSON method in the advanced documentation.

Step 4: Test your workflow

  1. Click on Execute Workflow (the play button at the bottom)

  2. Wait a few seconds for the PDF to generate

  3. You should see the document details in the output

  4. The PDF is now available at the download_url provided

Step 5: Download the PDF (optional)

If you want to download the PDF file as binary data in n8n:

  1. Enable Download File in the PDFMonkey node options

  2. The PDF will be available as binary data in the next nodes

Example: Form to PDF via Email

Let's create a more practical workflow that:

  1. Receives data from a webhook

  2. Generates a PDF with PDFMonkey

  3. Sends the PDF by email

The workflow structure

  1. Webhook node - receives form data

  2. PDFMonkey node - generates the document

  3. Send Email node - sends the PDF as attachment

Configuration

Webhook node:

  • Set to POST method

  • Path: /generate-pdf

PDFMonkey node:

  • Operation: Generate Document

  • Select your template

  • Map webhook data to template variables:

    • name{{ $json.name }}

    • favoriteNumber{{ $json.favoriteNumber }}

  • Enable Download File option

Send Email node:

  • Use Gmail, SendGrid, or any SMTP service

  • In attachments, reference the PDFMonkey binary data:

    • Property Name: data

    • File Name: document.pdf

Congrats!

You've successfully generated your first PDFMonkey Document using n8n! 🎉

Want to know more?

To learn more about the different options you can use when using PDFMonkey with n8n, head to our more thorough documentation on the integration.

Document generation options in n8nReacting to generated documents in n8nWhat can you do with PDFMonkey?

Last updated

Was this helpful?