Skip to main content

n8n

Prerequisites

  • A PolyDoc account and API key — sign up for free, no credit card required. The free plan includes 150 PDF conversions per month.
  • An n8n instance — self-host for free or use n8n Cloud.

Use Case 1: Generate PDFs from Spreadsheet Data

Automatically generate an invoice PDF for every new row added to a Google Sheet and email it to the recipient.
Google Sheets trigger (new row) → HTTP Request (PolyDoc API) → Gmail

Create a new workflow

Open your n8n instance and click Add workflow. Give it a descriptive name like "Invoices → PDF → Email".

Screenshot placeholder: /img/guides/n8n/n8n-uc1-create-workflow.png

Add a Google Sheets trigger node

Add a worksheet with column headers that match your PolyDoc template. The example below uses an invoices tab and one sample row; you can import data via File → Import (CSV/XLSX).

invoice_numberinvoice_dateinvoice_due_dateinvoice_subtotalinvoice_tax_rateinvoice_tax_amountinvoice_totalcustomer_namecustomer_emailcustomer_streetcustomer_citycustomer_country
INV-2026-0012026-01-152026-02-1412000.11201320John Doejohn.doe@example.com456 Customer AvenueBeautiful CityUK

Click Add first step and select Google Sheets → On Row Added. Connect your Google account, choose your spreadsheet, and select the invoices tab.

n8n will poll for new rows at the interval you configure (default: every minute). Click Fetch Test Event to pull in a sample row.

Screenshot placeholder: /img/guides/n8n/n8n-uc1-sheets-trigger.png

Add an HTTP Request node for PolyDoc

Add an HTTP Request node after the trigger and configure:

  • Method: POST
  • URL: https://api.polydoc.tech/pdf/convert
  • Authentication: Generic Credential Type → Header Auth
  • Create a credential with Name Authorization and Value Bearer YOUR_API_KEY (get your key from the Dashboard)
  • Add header: X-Sandbox = true
  • Body Content Type: JSON
  • Specify Body: use JSON and map row fields with expressions like {{ $json.customer_name }}
  • Options → Response: set Response Format to File so the PDF binary is available for the next node
Screenshot placeholder: /img/guides/n8n/n8n-uc1-http-request.png

Send the PDF by email

Add a Gmail node (or any email node) after the HTTP Request. Configure:

  • To: {{ $('Google Sheets Trigger').item.json.customer_email }}
  • Subject: Your PDF — {{ $('Google Sheets Trigger').item.json.invoice_number }}
  • Attachments: select the binary data from the HTTP Request node
Screenshot placeholder: /img/guides/n8n/n8n-uc1-gmail-node.png

Execute and activate the workflow

Click Test workflow to run it once with a sample row. Verify the PDF arrives in the recipient's inbox. When satisfied, toggle the workflow to Active so it runs automatically on new rows.

Screenshot placeholder: /img/guides/n8n/n8n-uc1-activate.png

Use Case 2: Webhook-Triggered PDF

Accept incoming JSON via a webhook, generate a PDF with PolyDoc, and return it directly in the HTTP response.
Webhook node → HTTP Request (PolyDoc API) → Respond to Webhook

Add a Webhook node

Create a new workflow. Add a Webhook node as the trigger. Set the HTTP Method to POST. Copy the Test URL shown in the node — you'll use it in the next step.

Screenshot placeholder: /img/guides/n8n/n8n-uc2-webhook-node.png

Send test data to the webhook

Send a test POST request with JSON data to the webhook URL. For example using curl:

curl -X POST <YOUR_TEST_URL> \
  -H "Content-Type: application/json" \
  -d '{"name": "Jane Doe", "amount": "€1,200.00"}'

n8n will capture the payload and display the received fields in the Webhook node output.

Screenshot placeholder: /img/guides/n8n/n8n-uc2-test-webhook.png

Add an HTTP Request node for PolyDoc

Add an HTTP Request node and configure it the same way as in Use Case 1:

  • URL: https://api.polydoc.tech/pdf/convert
  • Method: POST
  • Header Auth credential: Authorization = Bearer YOUR_API_KEY
  • Header: X-Sandbox = true
  • JSON body: map webhook fields using {{ $json.name }}, {{ $json.amount }}, etc.
  • Response Format: File
Screenshot placeholder: /img/guides/n8n/n8n-uc2-http-request.png

Return the PDF in the response

Add a Respond to Webhook node. Set Respond With to Binary and select the PDF data from the previous node. This returns the generated PDF directly to the caller.

Screenshot placeholder: /img/guides/n8n/n8n-uc2-respond-webhook.png

Activate the workflow

Click Test workflow and send another POST to the test URL. Confirm the PDF is returned. Then toggle the workflow to Active — the Production URL (different from the test URL) will be live and ready to accept requests.

Screenshot placeholder: /img/guides/n8n/n8n-uc2-activate.png