{
  "name": "Generate Quote PDFs in n8n",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger",
      "name": "When clicking Execute",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Replace this node with whatever already holds your data.\n// The field names below are what the template reads.\nreturn [{ json: {\n    \"quoteNumber\": \"Q-2026-084\",\n    \"issueDate\": \"27 Nov 2026\",\n    \"validUntil\": \"27 Dec 2026\",\n    \"currency\": \"EUR\",\n    \"subtotal\": \"14400.00\",\n    \"discount\": \"900.00\",\n    \"total\": \"13500.00\",\n    \"summary\": \"Rebuild of the customer portal, delivered in three increments with a working release at the end of each.\",\n    \"nextStep\": \"Reply to this email to accept. We can start in the week of 5 January.\",\n    \"owner\": {\n      \"name\": \"Mara Vogt\",\n      \"email\": \"mara@northwind.studio\",\n      \"company\": \"Northwind Studio GmbH\"\n    },\n    \"customer\": {\n      \"name\": \"Acme Retail BV\",\n      \"contact\": \"Jules Berger, Head of Digital\"\n    },\n    \"items\": [\n      {\n        \"title\": \"Discovery and architecture\",\n        \"detail\": \"Workshops, data model, delivery plan\",\n        \"days\": 8,\n        \"rate\": 900\n      },\n      {\n        \"title\": \"Portal implementation\",\n        \"detail\": \"Front end, API integration, tests\",\n        \"days\": 6,\n        \"rate\": 900\n      },\n      {\n        \"title\": \"Handover\",\n        \"detail\": \"Documentation, two training sessions\",\n        \"days\": 2,\n        \"rate\": 900\n      }\n    ]\n  } }];"
      },
      "id": "quote-data",
      "name": "Quote data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "resource": "convert",
        "operation": "htmlToPdf",
        "html": "=<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\" />\n  <title>Quote {{ $json.quoteNumber }}</title>\n  <style>\n    * { box-sizing: border-box; }\n    body {\n      margin: 0;\n      padding: 18mm 16mm;\n      font-family: Inter, Arial, Helvetica, sans-serif;\n      font-size: 10.5pt;\n      color: #111827;\n      line-height: 1.5;\n    }\n    h1 { font-size: 22pt; margin: 0; letter-spacing: -0.02em; }\n    h2 { font-size: 12pt; margin: 0 0 6px; }\n    .muted { color: #6b7280; }\n    .small { font-size: 9pt; }\n    .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }\n    .label { font-size: 8pt; text-transform: uppercase; letter-spacing: 0.08em; color: #6b7280; margin-bottom: 4px; }\n    .rule { border: 0; border-top: 1px solid #e5e7eb; margin: 20px 0; }\n    table { width: 100%; border-collapse: collapse; }\n    th {\n      text-align: left;\n      font-size: 8pt;\n      text-transform: uppercase;\n      letter-spacing: 0.08em;\n      color: #6b7280;\n      border-bottom: 1px solid #e5e7eb;\n      padding: 0 0 8px;\n    }\n    td { padding: 9px 0; border-bottom: 1px solid #f3f4f6; vertical-align: top; }\n    .num { text-align: right; white-space: nowrap; }\n    .totals { margin-top: 18px; margin-left: auto; width: 55%; }\n    .totals td { border: 0; padding: 4px 0; }\n    .grand td { border-top: 2px solid #111827; padding-top: 10px; font-weight: 700; font-size: 12pt; }\n    .badge { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #eef2ff; color: #4338ca; font-size: 8pt; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }\n    .foot { position: fixed; bottom: 10mm; left: 16mm; right: 16mm; font-size: 8pt; color: #9ca3af; border-top: 1px solid #f3f4f6; padding-top: 6px; }\n    @media print {\n      tr { page-break-inside: avoid; }\n      thead { display: table-header-group; }\n    }\n  </style>\n</head>\n<body>\n<div class=\"row\">\n  <div>\n    <span class=\"badge\">Quote</span>\n    <h1 style=\"margin-top:10px\">{{ $json.quoteNumber }}</h1>\n  </div>\n  <div class=\"num small muted\">\n    <div>Prepared {{ $json.issueDate }}</div>\n    <div><strong>Valid until {{ $json.validUntil }}</strong></div>\n  </div>\n</div>\n\n<hr class=\"rule\" />\n\n<div class=\"row\">\n  <div>\n    <div class=\"label\">Prepared for</div>\n    <strong>{{ $json.customer.name }}</strong><br />\n    <span class=\"muted\">{{ $json.customer.contact }}</span>\n  </div>\n  <div>\n    <div class=\"label\">Prepared by</div>\n    <strong>{{ $json.owner.name }}</strong><br />\n    <span class=\"muted\">{{ $json.owner.email }}</span>\n  </div>\n</div>\n\n<p style=\"margin-top:20px\">{{ $json.summary }}</p>\n\n<table style=\"margin-top:20px\">\n  <thead>\n    <tr>\n      <th>Scope</th>\n      <th class=\"num\">Days</th>\n      <th class=\"num\">Rate</th>\n      <th class=\"num\">Amount</th>\n    </tr>\n  </thead>\n  <tbody>\n    {{ $json.items.map(item => `\n    <tr>\n      <td>\n        <strong>${item.title}</strong><br />\n        <span class=\"small muted\">${item.detail}</span>\n      </td>\n      <td class=\"num\">${item.days}</td>\n      <td class=\"num\">${item.rate}</td>\n      <td class=\"num\">${(item.days * item.rate).toFixed(2)}</td>\n    </tr>\n    `).join('') }}\n  </tbody>\n</table>\n\n<table class=\"totals\">\n  <tr>\n    <td class=\"muted\">Subtotal</td>\n    <td class=\"num\">{{ $json.subtotal }} {{ $json.currency }}</td>\n  </tr>\n  <tr>\n    <td class=\"muted\">Discount</td>\n    <td class=\"num\">-{{ $json.discount }} {{ $json.currency }}</td>\n  </tr>\n  <tr class=\"grand\">\n    <td>Total</td>\n    <td class=\"num\">{{ $json.total }} {{ $json.currency }}</td>\n  </tr>\n</table>\n\n<div style=\"margin-top:28px\">\n  <div class=\"label\">Next step</div>\n  <p class=\"small\">{{ $json.nextStep }}</p>\n</div>\n\n<div class=\"foot\">{{ $json.owner.company }} · This quote is not an invoice</div>\n</body>\n</html>",
        "outputFilenamePdf": "quote-pdf-n8n.pdf"
      },
      "id": "render-the-quote",
      "name": "Render the quote",
      "type": "@custom-js/n8n-nodes-pdf-toolkit-v2.pdfToolkit",
      "typeVersion": 1,
      "position": [
        440,
        0
      ],
      "credentials": {
        "customJsApi": {
          "id": "1",
          "name": "CustomJS account"
        }
      }
    }
  ],
  "connections": {
    "When clicking Execute": {
      "main": [
        [
          {
            "node": "Quote data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quote data": {
      "main": [
        [
          {
            "node": "Render the quote",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}
