Scheduled report as a PDF, sent by email (n8n)

An n8n workflow that fetches data on a schedule, builds a color-coded HTML report, renders it to PDF and emails it every morning.

Last updated

Operations render_html_to_pdf (POST /v1/render)
Platforms n8n
Nodes Schedule Trigger, HTTP Request, Code, HTTP Request, Gmail

Every morning at 7:00 this workflow fetches records from an API, builds one HTML report and emails it as a PDF. The sample tracks expiry dates, such as vehicle insurance, inspections and permits. It groups them by urgency: expired in red, due within 7 days in orange, due within 30 days in yellow.

The same chain serves a weekly status digest or a monthly client report. Change the schedule, the data source and the HTML. The report is A4 landscape, with the date in the page header and page numbers in the footer.

The steps

  1. Every day at 7:00 (Schedule Trigger). Runs in the workflow's time zone.
  2. Fetch records (HTTP Request). Reads a JSON array of records with name, type and an ISO date expires.
  3. Build report HTML (Code). Runs once for all records, keeps those expired or due within 30 days, sorts them by date and color-codes them.
  4. Render PDF (HTTP Request). POSTs {"html": ..., "filename": ...} to https://api.pdfrender.dev/v1/render and puts the PDF in the binary field data.
  5. Email the PDF (Gmail). Attaches data and sends it to your team.

Fetch records carries pinned sample records, so Execute workflow runs the whole chain before you point it at your API. Headers and footers use CSS @page rules (page headers and footers).

Get the workflow

Download workflow.json and its setup notes from GitHub, then use Import from File in n8n. Every node ships with n8n, so the workflow runs on n8n Cloud and self-hosted n8n with nothing to install.

Set up the render step

Render PDF comes set up. Only the credential is yours to add:

  • Method POST, URL https://api.pdfrender.dev/v1/render.
  • Authentication: Generic Credential Type, Header Auth. Create a credential with the name X-API-Key and your key as the value.
  • Send Body: JSON, with html set to the Code node's output and a filename with the date.
  • Options > Response > Response Format: File, Put Output in Field data.

Get your API key. Each render costs 1 credit, whatever its page count, and a failed render costs nothing.

FAQ

Can it send a weekly or monthly client report instead?
Yes. Set the Schedule Trigger's interval to weeks or months and point the fetch step at the client's data. Then change the HTML in the Code node. Any n8n node that outputs items can replace the Fetch records step, for example a database query or Google Sheets.
What if nothing is due?
The report still goes out and says that nothing expires in the next 30 days. To skip the email on such days, add an If node after the Code node that checks count.