Thank you very much,
Unfortunately I get TypeError: JSDOM is not a constructor
with the following flow:
[
{
"id": "ee71cb46e6084549",
"type": "template",
"z": "9a9055680f904d80",
"name": "",
"field": "generated_html",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "\"<!doctype html>\n<html>\n<head>\n<style>\n body {\n background: url('https://cloudlog.online360.at/qslprinter/radio_qsl_sql_bg_withouttext.jpg');\n background-repeat: no-repeat;\n background-size: 140mm 90mm;\n font-family: Arial, Helvetica, sans-serif;\n }\n html {\n height: 100%;\n }\n #sql {\n margin-left: 5mm;\n margin-top: 15mm;\n font-size: 12px;\n }\n #address {\n margin-left: 95mm;\n margin-top: -10mm;\n font-size: 14px;\n font-weight: bold;\n }\n table {\n width: 120mm;\n margin-top: 20mm;\n margin-left: 5mm;\n }\n table, th, td {\n font-size: 13px;\n border: 1px solid;\n text-align: center;\n border-collapse: collapse;\n }\n th, td {\n padding: 5px;\n }\n</style>\n</head>\n<body>\n <div id=\"sql\">SELECT *<br>FROM logbook<br>WHERE callsign='OE3BIO' AND partner='{{COL_CALL}}'<br>ORDER BY date DESC </div>\n <div id=\"address\">To radio: {{COL_CALL}}\n <br>\n {{#COL_QSL_VIA}}\n <b>via {{COL_QSL_VIA}}</b>\n {{/COL_QSL_VIA}}\n </div>\n <table>\n <tr>\n <th>YEAR</th>\n <th>MONTH</th>\n <th>DAY</th>\n <th>TIME (UTC)</th>\n <th>BAND</th>\n <th>MODE</th>\n <th>RST</th>\n </tr>\n <tr>\n <td>{{year}}</td>\n <td>{{month}}</td>\n <td>{{day}}</td>\n <td>{{time}}</td>\n <td>{{COL_BAND}}</td>\n <td>{{COL_MODE}}</td>\n <td>{{COL_RST_SENT}}</td>\n </tr>\n </table>\n</body>\n</html>\"",
"output": "str",
"x": 900,
"y": 480,
"wires": [
[
"834be93ce354c306"
]
]
},
{
"id": "b80b61d89ced5bf4",
"type": "inject",
"z": "9a9055680f904d80",
"name": "inject demo",
"props": [
{
"p": "partner",
"v": "ABC123",
"vt": "str"
},
{
"p": "filename",
"v": "/media/qsl.pdf",
"vt": "str"
},
{
"p": "manager",
"v": "CBA321",
"vt": "str"
},
{
"p": "COL_TIME_OFF",
"v": "2022-09-05 20:33:00",
"vt": "str"
},
{
"p": "COL_MODE",
"v": "FT8",
"vt": "str"
},
{
"p": "COL_BAND",
"v": "20m",
"vt": "str"
},
{
"p": "COL_RST_SENT",
"v": "-16",
"vt": "str"
},
{
"p": "COL_QSL_SENT",
"v": "R",
"vt": "str"
},
{
"p": "COL_QSL_SENT",
"v": "R",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 390,
"y": 480,
"wires": [
[
"ee71cb46e6084549"
]
]
},
{
"id": "1f5a7fe3013edd67",
"type": "mysql",
"z": "9a9055680f904d80",
"mydb": "67a5a532e5304528",
"name": "",
"x": 730,
"y": 160,
"wires": [
[
"9f0f9ab18c1b3975",
"0c360a6d178ffda4"
]
]
},
{
"id": "0340d4c330c4e0f6",
"type": "function",
"z": "9a9055680f904d80",
"name": "Get QSOs",
"func": "msg.payload = \"\"\nmsg.topic = 'SELECT COL_PRIMARY_KEY,COL_CALL,COL_QSL_VIA,COL_TIME_ON,COL_MODE,COL_BAND,COL_RST_SENT,COL_QSL_SENT,COL_QSL_SENT FROM TABLE_HRD_CONTACTS_V01 WHERE COL_QSL_SENT=\"R\" ';\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 160,
"wires": [
[
"1f5a7fe3013edd67"
]
]
},
{
"id": "8b3132695fdda741",
"type": "inject",
"z": "9a9055680f904d80",
"name": "Trigger QSL card generation",
"props": [
{
"p": "payload"
},
{
"p": "filename",
"v": "/media/qsl.pdf",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 300,
"y": 160,
"wires": [
[
"e60da31cd797efdf"
]
]
},
{
"id": "ea741ffad455ff94",
"type": "change",
"z": "9a9055680f904d80",
"name": "",
"rules": [
{
"t": "set",
"p": "COL_CALL",
"pt": "msg",
"to": "payload.COL_CALL",
"tot": "msg"
},
{
"t": "set",
"p": "COL_QSL_VIA",
"pt": "msg",
"to": "payload.COL_QSL_VIA",
"tot": "msg"
},
{
"t": "set",
"p": "COL_MODE",
"pt": "msg",
"to": "payload.COL_MODE",
"tot": "msg"
},
{
"t": "set",
"p": "COL_BAND",
"pt": "msg",
"to": "payload.COL_BAND",
"tot": "msg"
},
{
"t": "set",
"p": "COL_RST_SENT",
"pt": "msg",
"to": "payload.COL_RST_SENT",
"tot": "msg"
},
{
"t": "set",
"p": "COL_QSL_SENT",
"pt": "msg",
"to": "payload.COL_QSL_SENT",
"tot": "msg"
},
{
"t": "set",
"p": "filename",
"pt": "msg",
"to": "\"/media/qsl/\" & $.payload.COL_PRIMARY_KEY & \".pdf\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 300,
"wires": [
[
"a7bc6ca94c8649cb"
]
]
},
{
"id": "a7bc6ca94c8649cb",
"type": "moment",
"z": "9a9055680f904d80",
"name": "get year",
"topic": "",
"input": "COL_TIME_ON_formatted",
"inputType": "msg",
"inTz": "ETC/UTC",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "YYYY",
"locale": "C",
"output": "year",
"outputType": "msg",
"outTz": "ETC/UTC",
"x": 640,
"y": 300,
"wires": [
[
"6eb1f5ba2fddb727"
]
]
},
{
"id": "6eb1f5ba2fddb727",
"type": "moment",
"z": "9a9055680f904d80",
"name": "get month",
"topic": "",
"input": "COL_TIME_ON_formatted",
"inputType": "msg",
"inTz": "ETC/UTC",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "MM",
"locale": "C",
"output": "month",
"outputType": "msg",
"outTz": "ETC/UTC",
"x": 640,
"y": 340,
"wires": [
[
"7adeee6b4f9eebf3"
]
]
},
{
"id": "7adeee6b4f9eebf3",
"type": "moment",
"z": "9a9055680f904d80",
"name": "get day",
"topic": "",
"input": "COL_TIME_ON_formatted",
"inputType": "msg",
"inTz": "ETC/UTC",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "DD",
"locale": "C",
"output": "day",
"outputType": "msg",
"outTz": "ETC/UTC",
"x": 640,
"y": 380,
"wires": [
[
"58994e7e0483c7ac"
]
]
},
{
"id": "58994e7e0483c7ac",
"type": "moment",
"z": "9a9055680f904d80",
"name": "get time",
"topic": "",
"input": "COL_TIME_ON_formatted",
"inputType": "msg",
"inTz": "ETC/UTC",
"adjAmount": 0,
"adjType": "days",
"adjDir": "add",
"format": "HH:mm",
"locale": "C",
"output": "time",
"outputType": "msg",
"outTz": "ETC/UTC",
"x": 640,
"y": 420,
"wires": [
[
"ee71cb46e6084549"
]
]
},
{
"id": "6c1cd0a9d0a25243",
"type": "string",
"z": "9a9055680f904d80",
"name": "",
"methods": [
{
"name": "toString",
"params": []
},
{
"name": "replaceAll",
"params": [
{
"type": "str",
"value": " GMT+0200 (Central European Summer Time)"
},
{
"type": "str",
"value": " UTC"
}
]
}
],
"prop": "payload.COL_TIME_ON",
"propout": "COL_TIME_ON_formatted",
"object": "msg",
"objectout": "msg",
"x": 370,
"y": 240,
"wires": [
[
"ea741ffad455ff94"
]
]
},
{
"id": "9f0f9ab18c1b3975",
"type": "split",
"z": "9a9055680f904d80",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 890,
"y": 180,
"wires": [
[
"6c1cd0a9d0a25243"
]
]
},
{
"id": "7ab6f15f763da16a",
"type": "function",
"z": "9a9055680f904d80",
"name": "function 52",
"func": "const html_to_pdf = new htmlPdfNode();\n//let generated_html = msg.generated_html;\n\nlet options = { format: 'A4', path: '/media/qsl/test.pdf' };\n//let options = { width: '140m', height: '90mm' };\n// Example of options with args //\n// let options = { format: 'A4', args: ['--no-sandbox', '--disable-setuid-sandbox'] };\n\nlet file = { content: \"<h1>Welcome to html-pdf-node</h1>\" };\n\nhtml_to_pdf.generatePdf(file, options).then(pdfBuffer => {\n console.log(\"PDF Buffer:-\", pdfBuffer);\n});\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [
{
"var": "htmlPdfNode",
"module": "html-pdf-node"
},
{
"var": "bluebird",
"module": "bluebird"
},
{
"var": "handlebars",
"module": "handlebars"
},
{
"var": "inlineCss",
"module": "inline-css"
},
{
"var": "puppeteer",
"module": "puppeteer"
}
],
"x": 1090,
"y": 420,
"wires": [
[
"041f05f7276be52e",
"cd8e27f9212632c3"
]
]
},
{
"id": "834be93ce354c306",
"type": "change",
"z": "9a9055680f904d80",
"name": "",
"rules": [
{
"t": "set",
"p": "width",
"pt": "msg",
"to": "140",
"tot": "num"
},
{
"t": "set",
"p": "height",
"pt": "msg",
"to": "90",
"tot": "num"
},
{
"t": "set",
"p": "pageOrientation",
"pt": "msg",
"to": "landscape",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1060,
"y": 480,
"wires": [
[
"11a2106c4a5c8d06"
]
]
},
{
"id": "0c360a6d178ffda4",
"type": "debug",
"z": "9a9055680f904d80",
"name": "debug 47",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 980,
"y": 120,
"wires": []
},
{
"id": "e60da31cd797efdf",
"type": "function",
"z": "9a9055680f904d80",
"name": "Get QSOs",
"func": "msg.payload = \"\"\nmsg.topic = 'SELECT COL_PRIMARY_KEY,COL_CALL,COL_QSL_VIA,COL_TIME_ON,COL_MODE,COL_BAND,COL_RST_SENT,COL_QSL_SENT,COL_QSL_SENT FROM TABLE_HRD_CONTACTS_V01 WHERE COL_CALL=\"DK1PU\" ';\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 530,
"y": 120,
"wires": [
[
"1f5a7fe3013edd67"
]
]
},
{
"id": "075ae101fed922d1",
"type": "pdfmake",
"z": "9a9055680f904d80",
"name": "",
"outputType": "Buffer",
"inputProperty": "payload",
"options": "{}",
"outputProperty": "payload",
"x": 1340,
"y": 660,
"wires": [
[
"4e692a74d7a1230c"
]
]
},
{
"id": "11a2106c4a5c8d06",
"type": "function",
"z": "9a9055680f904d80",
"name": "HTML to docDef",
"func": "const { JSDOM } = jsdom;\nconst { window } = new JSDOM(\"\");\n\nconst html = htmlToPdfmake(msg.payload, { window: window });\n\nconst docDefinition = {\n // a string or { width: number, height: number }\n pageSize: {\n width: msg.width ,\n height: msg.height\n },\n\n // by default we use portrait, you can change it to landscape if you wish\n pageOrientation: msg.pageOrientation || 'landscape',\n\n // [left, top, right, bottom] or [horizontal, vertical] or just a number for equal margins\n //pageMargins: [40, 60, 40, 60],\n\n content: [\n html\n ]\n};\n\n\nmsg.payload = docDefinition\n\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [
{
"var": "htmlToPdfmake",
"module": "html-to-pdfmake"
},
{
"var": "jsdom",
"module": "jsdom"
}
],
"x": 1340,
"y": 600,
"wires": [
[
"075ae101fed922d1"
]
]
},
{
"id": "4e692a74d7a1230c",
"type": "file",
"z": "9a9055680f904d80",
"name": "",
"filename": "filename",
"filenameType": "msg",
"appendNewline": false,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 1360,
"y": 720,
"wires": [
[
"9ba7ebda55b1d722"
]
]
},
{
"id": "9ba7ebda55b1d722",
"type": "debug",
"z": "9a9055680f904d80",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "filename",
"targetType": "msg",
"statusVal": "filename",
"statusType": "auto",
"x": 1350,
"y": 780,
"wires": []
},
{
"id": "67a5a532e5304528",
"type": "MySQLdatabase",
"name": "cloudlog db",
"host": "0.0.0.0",
"port": "3306",
"db": "cloudlog",
"tz": "",
"charset": "UTF8"
}
]
jsdom is set under modules as I copied the node from your side.