{
  "name": "HTML to PDF invoice with Cofferdock",
  "nodes": [
    {
      "parameters": {
        "content": "## HTML to PDF (Cofferdock)\n1. Open **HTML to PDF** and replace `YOUR_API_KEY` with your key (dashboard → + Create key).\n2. Change the order in **Invoice data** (or connect your webhook, form or Google Sheets here).\n3. Click **Test workflow**: the last node returns the PDF as a file (`data`), ready for Gmail or Google Drive.\n\nGuide: https://cofferdock.com/blog/html-to-pdf-n8n",
        "height": 280,
        "width": 440
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-520, -320],
      "name": "Sticky Note",
      "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f01"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-480, 40],
      "name": "When clicking Test workflow",
      "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f02"
    },
    {
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            { "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f10", "name": "number", "value": "INV-1042", "type": "string" },
            { "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f11", "name": "customer", "value": "Acme Ltd", "type": "string" },
            { "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f12", "name": "item", "value": "Website maintenance (September)", "type": "string" },
            { "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f13", "name": "total", "value": "€450.00", "type": "string" }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-240, 40],
      "name": "Invoice data",
      "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f03"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.cofferdock.com/pdf",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            { "name": "format", "value": "A4" },
            { "name": "margin", "value": "15" }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "x-api-key", "value": "YOUR_API_KEY" },
            { "name": "Content-Type", "value": "text/html" }
          ]
        },
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "text/html",
        "body": "=<html><body style=\"font-family:Arial,Helvetica,sans-serif;color:#222;margin:0\"><div style=\"display:flex;justify-content:space-between;align-items:flex-start;border-bottom:3px solid #8a5210;padding-bottom:16px\"><div style=\"font-size:28px;font-weight:800\">Your Company</div><div style=\"text-align:right\"><div style=\"font-size:22px;font-weight:700\">Invoice {{ $json.number }}</div><div style=\"color:#666\">{{ $now.toFormat('yyyy-LL-dd') }}</div></div></div><p style=\"margin:28px 0 8px;color:#666\">Bill to</p><p style=\"margin:0;font-size:18px;font-weight:700\">{{ $json.customer }}</p><table style=\"width:100%;border-collapse:collapse;margin-top:32px\"><tr style=\"background:#f4ede4\"><th style=\"text-align:left;padding:10px\">Item</th><th style=\"text-align:right;padding:10px\">Amount</th></tr><tr><td style=\"padding:10px;border-bottom:1px solid #ddd\">{{ $json.item }}</td><td style=\"padding:10px;border-bottom:1px solid #ddd;text-align:right\">{{ $json.total }}</td></tr></table><p style=\"text-align:right;font-size:22px;font-weight:800;margin-top:24px\">Total: {{ $json.total }}</p></body></html>",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [0, 40],
      "name": "HTML to PDF",
      "id": "8d4e2c6a-1b3f-4f0a-a2d4-6c9e1b7a5f04"
    }
  ],
  "connections": {
    "When clicking Test workflow": { "main": [[{ "node": "Invoice data", "type": "main", "index": 0 }]] },
    "Invoice data": { "main": [[{ "node": "HTML to PDF", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" }
}
