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 with WeasyPrint and emails it every morning.
Last updated
| Operations | weasyprint_render (POST /v1/weasyprint/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 example 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
- Every day at 7:00 (Schedule Trigger). Runs in the workflow's time zone.
- Fetch records (HTTP Request). Reads a JSON array of records with
name,typeand an ISO dateexpires. - 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.
- Render PDF (HTTP Request). POSTs
{"html": ..., "filename": ...}tohttps://api.pagespool.com/v1/weasyprint/renderand puts the PDF in the binary fielddata. - Email the PDF (Gmail). Attaches
dataand sends it to your team.
Headers and footers use CSS @page rules
(page headers and footers).
Set up the render step
- Method POST, URL
https://api.pagespool.com/v1/weasyprint/render. - Authentication: Generic Credential Type, Header Auth, with the name
X-API-Keyand your key as the value. - Send Body: JSON, with
htmlset to the Code node's output and afilenamewith 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 HTTP Request 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.