Generate Monthly Report PDFs in n8n

Dashboards are good at answering questions and bad at arriving in an inbox. This workflow runs on a schedule, reads the numbers, and sends a report that someone can read on a phone without a login. The layout is a template, so the KPI tiles and the tables are yours to change.

600 free requests / month, no credit card

Document
Report
Platform
n8n, cloud or self-hosted
Runs
Scheduled, monthly
Output
PDF, binary

// live preview

The report that lands in the inbox

The KPI tiles and the channel table are both loops, so adding a metric is a line of JSON rather than a layout change. Edit the numbers and render it.

// the workflow

Schedule, gather, render, send

Schedule Trigger
first of the month, 06:00
Gather sources
analytics, database, billing
Shape the report
Code node, KPIs and deltas
CustomJS
Convert, HTML to PDF
Send Email
attached, to the owner
The Generate Monthly Report PDFs in n8n workflow on the n8n canvas
The imported workflow in n8n, straight after importing the file above.

Import the workflow and set the schedule. The merge step matters more than it looks: pulling each source in its own node and combining them once keeps a single failing API from taking down the whole report.

Turning raw numbers into KPI tiles

// Code node, one place where every delta is formatted the same way
const pct = (now, prev) => ((now - prev) / prev) * 100;

const kpi = (label, value, now, prev, unit = '%') => {
  const delta = pct(now, prev);
  return {
    label,
    value,
    change: `${delta >= 0 ? '+' : ''}${delta.toFixed(1)}${unit} vs last month`,
    color: delta >= 0 ? '#047857' : '#b91c1c',
  };
};

return [{ json: {
  period: new Date().toLocaleString('en-GB', { month: 'long', year: 'numeric' }),
  kpis: [
    kpi('Sessions', $json.sessions.toLocaleString(), $json.sessions, $json.sessionsPrev),
    kpi('Signups', $json.signups.toLocaleString(), $json.signups, $json.signupsPrev),
  ],
}}];

What the node looks like

The CustomJS node parameters in n8n, showing resource and operation

// step by step

Build it yourself

  1. 1

    Install the CustomJS node

    Open the node panel and search for CustomJS. The node is published, so on n8n Cloud it is in the list already and nothing has to be installed. On a self-hosted instance, add it once under Settings, Community nodes as @custom-js/n8n-nodes-pdf-toolkit-v2. The installation page has the details.

  2. 2

    Add your API key

    Create a credential of type CustomJS API and paste the key from your workspace. One key covers PDF, screenshots and the other endpoints.

  3. 3

    Put the schedule first

    A Schedule Trigger on the first of the month at 06:00 means the report is waiting before anyone asks for it. That is the whole value of a report over a dashboard.

  4. 4

    Gather each source in its own node

    Analytics, database, billing. Keeping them separate means a slow API delays the report instead of breaking it, and Continue on Fail lets a missing section render as a gap rather than an error.

  5. 5

    Format the numbers before the template

    Thousand separators, percentages and the colour of a delta belong in a Code node, not in the HTML. One place for the formatting means every tile agrees on what a positive change looks like.

  6. 6

    Send it to a person, not a channel

    Attach the PDF to an email addressed to the owner named on the report. A report in a shared channel is read by nobody in particular.

// html template

KPI tiles without a chart library

The tiles are a flex row and the colour comes from the data, which means a falling metric goes red without any logic in the template.

The tile loop

<div class="row" style="gap:12px">
  {% for kpi in kpis %}
  <div style="flex:1;border:1px solid #e5e7eb;border-radius:8px;padding:12px">
    <div class="label">{{ kpi.label }}</div>
    <div style="font-size:18pt;font-weight:700">{{ kpi.value }}</div>
    <div class="small" style="color:{{ kpi.color }}">{{ kpi.change }}</div>
  </div>
  {% endfor %}
</div>

Headers that repeat across pages

@media print {
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
}

For an actual chart, render it as an image URL in the gathering step and place it with an img tag, or capture a dashboard with the dashboard screenshot template and embed that.

Questions about this template

Put next month on a schedule

Create a workspace, add the API key, import the workflow and set the trigger.