
Most of the available PDF tools are expensive and for the free options, it is hard to automate. As I work more and more with n8n, I have adopted the idea of making my DIY internal tools to manage different tasks and processes. This workflow came as a need to automate my own PDFs within n8n without the haste of extra coding or premium tools.
How does it work
We create a code snippet that formats the text into your desired HTML format. For the less technical users, you might need to use chat GPT/Claude to generate the desired code snippets to convert your JSON data in n8n into an HTML format. This HTML is sent to a web app endpoint and returns a drive URL and id with our newly generated PDF document
Setup
Google sheets
Before you begin, we will be setting up two code snippets
1. Google script code
2. HTML convertor code in n8n
This is the code snippet that we are going to copy and paste into Google Sheets
- Open Google Docs click on the extensions bar and select app scripts

2. When the new tab opens, copy and paste the code on the workflow into the google sheets and deploy as a web app.
Deploy → “Execute as me”, “Anyone can access” → Copy the URL.
N8n setup
When it comes to the second setup, this might vary from user to user and use case. You might need to repurpose your code to fit your specific datasets. You can test the code output via the Html node and make updates as needed.
How to generate PDFs with n8n and Google docs
To generate PDFs with n8n and Google docs, will create a workflow that sends the HTML data to the provided web app URL with the HTML as a URL-encoded body parameter. This returns the link to the pdf file and you can rename the file or manipulate it as needed
The request can be sent as below.
curl -X POST https://script.google.com/macros/s/your-script-id/exec \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "html=<your_invoice_html_here>"
This returns a json like this
{
"pdfUrl": "https://drive.google.com/file/d/ABC123/view",
"fileId": "ABC123"
}

In n8n, we rename the file name using the google Drive node and send it via email to any desired recipient or endpoint
This makes it easier to manage all pdfs within n8n and Google docs natively without requiring any third party tools/systems
You will end up with a setup like this

Final thoughts
This is still an experimental system and may have issues with highly visual and complex styles and features. For now we can generate a wide variety of pdf files including invoices, reports, quotes, project outlines among other stuff
AI is still a great enabler for creating and developing these workflows and setups. You can prompt it to create the coding logic and stitch it together with n8n to create an end to end backend logic for your operations
Code to the workflows