How to push multiple array pdfmake

please help to guidline code How to push multiple arry pdfmake 1 page

var stuff = msg.payload[];

var dd  = {
    content: stuff.map(function(item) {
        return { text: item, pageBreak: 'after'}
    })
};
msg.payload = dd;
return msg;

Firstly, this is not valid. And since you have not shown us what is inside msg.payload, I cannot say what the correct syntax is other than what you currently have will not work.

Show us in msg.payload?

TIP 1: Add a debug node & click the "copy value" button that appears under your mouse when you hover over the debug messages payload.

TIP 2: When you paste the copied payload, first press the </> code button on forum toolbar so that the data is surrounded by three ``` backticks

```
like this
```


is an error

var stuff = [
    'aaaaaaaaaaaaaaaaaaa',
    'bbbbbbbbbbbbbbbbbbb',
    'ccccccccccccccccccc',
    'ddddddddddddddddddd'
];

var dd  = {
    content: stuff.map(function(item) {
        return { text: item, pageBreak: 'after'}
    })
};

is it working but i want to add msg.paylod instead of stuff

[{"id":"d8bcc25e815f0bc3","type":"tab","label":"Flow 10","disabled":false,"info":"","env":[]},{"id":"f96b02b55ebe2d58","type":"file","z":"d8bcc25e815f0bc3","name":"","filename":"F:\\slip\\pdf\\1.pdf","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":1000,"y":360,"wires":[[]]},{"id":"37c96646d34db589","type":"debug","z":"d8bcc25e815f0bc3","name":"back","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":870,"y":420,"wires":[]},{"id":"3718debef43e7a59","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":350,"y":360,"wires":[["4b9876df06a0af8c"]]},{"id":"9eaa3571d98597e1","type":"pdfmake","z":"d8bcc25e815f0bc3","name":"pdf","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":830,"y":360,"wires":[["f96b02b55ebe2d58"]]},{"id":"a4f73f0372576a79","type":"function","z":"d8bcc25e815f0bc3","name":"","func":"var stuff = [\n    'aaaaaaaaaaaaaaaaaaa',\n    'bbbbbbbbbbbbbbbbbbb',\n    'ccccccccccccccccccc',\n    'ddddddddddddddddddd'\n];\nvar dd  = {\n    content: stuff.map(function(item) {\n        return { text: item, pageBreak: 'after'}\n    })\n};\nmsg.payload = dd;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":340,"wires":[["9eaa3571d98597e1"]]},{"id":"78f93f8b856472b2","type":"convert","z":"d8bcc25e815f0bc3","name":"","convertTo":"string","x":680,"y":420,"wires":[["a4f73f0372576a79"]]},{"id":"4b9876df06a0af8c","type":"random","z":"d8bcc25e815f0bc3","name":"","low":1,"high":10,"inte":"true","property":"payload","x":480,"y":340,"wires":[["78f93f8b856472b2"]]}]

Yes, I know it is an error - i already said it is invalid syntax.

If msg.payload contains this array then just change your first line of code to var stuff = msg.payload

That error means msg.payload is NOT an array. How did you set it?

i 'am not sure how to set pls advise thanks.

share your flow.

[{"id":"d8bcc25e815f0bc3","type":"tab","label":"Flow 10","disabled":false,"info":"","env":[]},{"id":"f96b02b55ebe2d58","type":"file","z":"d8bcc25e815f0bc3","name":"","filename":"F:\\slip\\pdf\\1.pdf","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":1000,"y":360,"wires":[[]]},{"id":"37c96646d34db589","type":"debug","z":"d8bcc25e815f0bc3","name":"back","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":300,"wires":[]},{"id":"3718debef43e7a59","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ee","payloadType":"str","x":210,"y":360,"wires":[["a4f73f0372576a79"]]},{"id":"9eaa3571d98597e1","type":"pdfmake","z":"d8bcc25e815f0bc3","name":"pdf","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":830,"y":360,"wires":[["f96b02b55ebe2d58"]]},{"id":"a4f73f0372576a79","type":"function","z":"d8bcc25e815f0bc3","name":"","func":"var stuff = msg.payload;\nvar dd  = {\n    content: stuff.map(function(item) {\n        return { text: item, pageBreak: 'after'}\n    })\n};\nmsg.payload = dd;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":360,"wires":[["9eaa3571d98597e1","37c96646d34db589"]]}]

This will never work. Your inject only has a string of ee

image

Where is your array of data?

sorry my point when reciving paylod 1 by 1 but pdf file can't new line in content

There are some good examples on the playground section of 'pdfmake.org' that might help you.

http://pdfmake.org/playground.html

Thnaks dynamicdave but i need get data from msg.paylaod wirte to pdf file,
issue is need to new line in conntent

You should have made this clear from the start.

You need to build up the array THEN send it.

e.g. ...

chrome_bW2lrEMTYw

[{"id":"3718debef43e7a59","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"add","payload":"hello","payloadType":"str","x":360,"y":320,"wires":[["a4f73f0372576a79"]]},{"id":"a4f73f0372576a79","type":"function","z":"d8bcc25e815f0bc3","name":"reset/add/get","func":"const lines = context.get(\"lines\") || [];\nif(msg.topic === \"reset\") {\n    context.set(\"lines\", [])\n    node.status({fill:\"grey\",shape:\"dot\",text:\"\"});\n    return\n}\nif (msg.topic === \"get\") {\n    msg.payload = lines\n    node.status({ fill: \"green\", shape: \"dot\", text: `${lines.length} line(s) released` });\n    return msg\n}\n\nif (msg.topic === \"add\") {\n    lines.push(msg.payload)\n}\nnode.status({ fill:\"yellow\",shape:\"dot\",text:`${lines.length} line(s) ready to send`});\ncontext.set(\"lines\", lines)","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":360,"wires":[["2f945b5388f9214f","c8efb2da664fc5f4"]]},{"id":"2f945b5388f9214f","type":"function","z":"d8bcc25e815f0bc3","name":"create dd","func":"var stuff = msg.payload;\nvar dd = {\n    content: stuff.map(function (item) {\n        return { text: item, pageBreak: 'after' }\n    })\n};\nmsg.payload = dd;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":360,"wires":[["f21ce917cd8df9ef"]]},{"id":"f21ce917cd8df9ef","type":"debug","z":"d8bcc25e815f0bc3","name":"Send to pdfmake","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"msg","x":950,"y":360,"wires":[]},{"id":"6d25e378e79cd3fd","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"add","payload":"data","payloadType":"str","x":360,"y":360,"wires":[["a4f73f0372576a79"]]},{"id":"8bac8a988db17a5a","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"add","payload":"the end","payloadType":"str","x":370,"y":400,"wires":[["a4f73f0372576a79"]]},{"id":"3d2f253a649b2551","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"reset","x":350,"y":260,"wires":[["a4f73f0372576a79"]]},{"id":"d84fc13ec02e66e5","type":"inject","z":"d8bcc25e815f0bc3","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"get","x":350,"y":460,"wires":[["a4f73f0372576a79"]]},{"id":"c8efb2da664fc5f4","type":"debug","z":"d8bcc25e815f0bc3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":320,"wires":[]}]

Hi Steve

i have multi payload in 1 time but wite to pdf is have 1 line
so how to wite all payload to pdf

[{"id":"5e2273f4fb49e337","type":"tab","label":"Flow 11","disabled":false,"info":"","env":},{"id":"e359c36aa00d7f17","type":"inject","z":"5e2273f4fb49e337","name":"F:\testlog\fail","props":[{"p":"path","v":"F:\testlog\fail","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":270,"y":180,"wires":[["3d93ab7cae16d359"]]},{"id":"3d93ab7cae16d359","type":"fs-ops-dir","z":"5e2273f4fb49e337","name":"get directory listing","path":"path","pathType":"msg","filter":".","filterType":"str","dir":"payload","dirType":"msg","x":190,"y":280,"wires":[["17341aae0bdf6ee8"]]},{"id":"17341aae0bdf6ee8","type":"split","z":"5e2273f4fb49e337","name":"","splt":"\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":390,"y":280,"wires":[["31485cf1e820b8b7"]]},{"id":"31485cf1e820b8b7","type":"function","z":"5e2273f4fb49e337","name":"create full path","func":"msg.file = msg.payload;\nmsg.filename = msg.path + "\\" + msg.file;\n//msg.filename = msg.path ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":130,"y":340,"wires":[["aad96892095bb134"]]},{"id":"aad96892095bb134","type":"delay","z":"5e2273f4fb49e337","name":"delay for viewing purposes","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":380,"y":340,"wires":[["407107c557a49f5c"]]},{"id":"407107c557a49f5c","type":"file in","z":"5e2273f4fb49e337","name":"","filename":"","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":600,"y":320,"wires":[["baed69a352954f6e"]]},{"id":"baed69a352954f6e","type":"switch","z":"5e2273f4fb49e337","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"{@RPT|","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":320,"wires":[["91fa19a0c0711e29"]]},{"id":"91fa19a0c0711e29","type":"function","z":"5e2273f4fb49e337","name":"build document definition","func":"//setup base document definition\nconst docdef = {\n "pageSize": "A4",\n "pageOrientation": "portrait",\n "pageMargins": [\n 40,\n 60,\n 40,\n 60\n ],\n "info": {\n "title": "awesome Document",\n "author": "john doe",\n "subject": "subject of document",\n "keywords": "keywords for document"\n },\n "content": [\n // {\n // "text": msg.payload,\n \n // "style": "header"\n // },\n // "This report gives an short overview, of the last work-shift data.",\n // {\n // "text": msg.payload,\n // "style": "subheader"\n // },\n // {\n // "text": "The following chart and table give an overview about the scanner-rates. Both include the global mean values of all scanners that are connected to the edge (including all PLCs)."\n // },\n \n // {\n // "text": msg.payload,\n \n // "style": "subheader"\n // },\n // "\n",\n // {\n // "table": {\n // "body": [\n // ["Timestamp", "GRRate", "NRRate"],\n // ["2021-01-26 14:30", 20, 80]\n // ]\n // }\n // },\n // "\n",\n // {\n // "text": "WMS Response-Times",\n // "style": "subheader"\n // },\n // {\n // "text": "The following chart and table give an overview about the WMS Response-Times. Both include the global mean values of all dispo-points that are connected to the edge (including all PLCs)."\n // },\n {\n "text": "ICT,{{{payload}}}",\n "style": "subheader"\n },\n "\n"+ msg.payload,\n // {\n // "table": {\n // "body": [\n // ["Timestamp", "Response<300", "Response<500", "Response<1000", "Response>1000"],\n // ["2021-01-26 14:30", 10, 30, 50, 20]\n // ]\n // }\n // }\n ],\n\n "styles": {\n "header": {\n "fontSize": 18,\n "bold": true\n },\n "subheader": {\n "fontSize": 15,\n "bold": true\n },\n "center":\n {\n "alignment": "center"\n }\n }\n\n}\n\n//Add the contents - some parts will be conditionally added based on msg.options\n\n//header\ndocdef.content.push("\n\n");\ndocdef.content.push({\n "text": "PDF Shift-Report",\n // "text": msg.payload,\n "style": "header"\n})\n\ndocdef.content.push("\n\n");\ndocdef.content.push('\n\n'+ msg.payload+'\n\n');\n//docdef.content.push("\n");\n\n\n\nmsg.payload = docdef;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":930,"y":340,"wires":[["a5c5cba1e79c554d"]]},{"id":"a5c5cba1e79c554d","type":"pdfmake","z":"5e2273f4fb49e337","name":"","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":1160,"y":360,"wires":[["1179333b4da515bd"]]},{"id":"1179333b4da515bd","type":"string","z":"5e2273f4fb49e337","name":"","methods":[{"name":"getRightMost","params":[{"type":"str","value":"\"}]}],"prop":"filename","propout":"file","object":"msg","objectout":"msg","x":1290,"y":360,"wires":[["de4dfde83f174195"]]},{"id":"de4dfde83f174195","type":"function","z":"5e2273f4fb49e337","name":"","func":"var now = new Date();\n// Create formatted time\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();\nvar mmm = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();\nvar ss = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();\n\n// file path with / at the end\nvar path = "F:\\slip\\pdf\\"; // This is the path\n//var filename = filename+".pdf"; // file name\nvar filename = msg.file+".pdf"; // file name\n//var filename = "cam3_"+yyyy+mm+dd+"-"+hh+mm+ss+".txt"; // file name\nmsg.filename = path + filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":1420,"y":360,"wires":[["7eba07998ca3e373"]]},{"id":"7eba07998ca3e373","type":"file","z":"5e2273f4fb49e337","name":"","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1580,"y":340,"wires":[]}]

[{"id":"5e2273f4fb49e337","type":"tab","label":"Flow 11","disabled":false,"info":"","env":[]},{"id":"e359c36aa00d7f17","type":"inject","z":"5e2273f4fb49e337","name":"F:\\testlog\\fail","props":[{"p":"path","v":"F:\\testlog\\fail","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":270,"y":180,"wires":[["3d93ab7cae16d359"]]},{"id":"3d93ab7cae16d359","type":"fs-ops-dir","z":"5e2273f4fb49e337","name":"get directory listing","path":"path","pathType":"msg","filter":"*.*","filterType":"str","dir":"payload","dirType":"msg","x":190,"y":280,"wires":[["17341aae0bdf6ee8"]]},{"id":"17341aae0bdf6ee8","type":"split","z":"5e2273f4fb49e337","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":390,"y":280,"wires":[["31485cf1e820b8b7"]]},{"id":"31485cf1e820b8b7","type":"function","z":"5e2273f4fb49e337","name":"create full path","func":"msg.file = msg.payload;\nmsg.filename = msg.path + \"\\\\\" + msg.file;\n//msg.filename = msg.path ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":130,"y":340,"wires":[["aad96892095bb134"]]},{"id":"aad96892095bb134","type":"delay","z":"5e2273f4fb49e337","name":"delay for viewing purposes","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":380,"y":340,"wires":[["407107c557a49f5c"]]},{"id":"407107c557a49f5c","type":"file in","z":"5e2273f4fb49e337","name":"","filename":"","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":600,"y":320,"wires":[["baed69a352954f6e"]]},{"id":"baed69a352954f6e","type":"switch","z":"5e2273f4fb49e337","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"{@RPT|","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":730,"y":320,"wires":[["91fa19a0c0711e29"]]},{"id":"91fa19a0c0711e29","type":"function","z":"5e2273f4fb49e337","name":"build document definition","func":"//setup base document definition\nconst docdef = {\n    \"pageSize\": \"A4\",\n    \"pageOrientation\": \"portrait\",\n    \"pageMargins\": [\n        40,\n        60,\n        40,\n        60\n    ],\n    \"info\": {\n        \"title\": \"awesome Document\",\n        \"author\": \"john doe\",\n        \"subject\": \"subject of document\",\n        \"keywords\": \"keywords for document\"\n    },\n    \"content\": [\n        // {\n          //   \"text\":  msg.payload,\n             \n         //    \"style\": \"header\"\n        // },\n        // \"This report gives an short overview, of the last work-shift data.\",\n       //  {\n        //    \"text\":  msg.payload,\n       //      \"style\": \"subheader\"\n       //  },\n        // {\n        //     \"text\": \"The following chart and table give an overview about the scanner-rates. Both include the global mean values of all scanners that are connected to the edge (including all PLCs).\"\n        // },\n        \n        // {\n        //     \"text\":  msg.payload,\n             \n         //    \"style\": \"subheader\"\n        // },\n       //  \"\\n\",\n        // {\n        //     \"table\": {\n        //         \"body\": [\n        //             [\"Timestamp\", \"GRRate\", \"NRRate\"],\n        //             [\"2021-01-26 14:30\", 20, 80]\n        //         ]\n        //     }\n        // },\n        // \"\\n\",\n        // {\n        //     \"text\": \"WMS Response-Times\",\n        //     \"style\": \"subheader\"\n        // },\n        // {\n        //     \"text\": \"The following chart and table give an overview about the WMS Response-Times. Both include the global mean values of all dispo-points that are connected to the edge (including all PLCs).\"\n        // },\n         {\n            \"text\": \"ICT,{{{payload}}}\",\n             \"style\": \"subheader\"\n         },\n         \"\\n\"+ msg.payload,\n        // {\n        //     \"table\": {\n        //         \"body\": [\n        //             [\"Timestamp\", \"Response<300\", \"Response<500\", \"Response<1000\", \"Response>1000\"],\n        //             [\"2021-01-26 14:30\", 10, 30, 50, 20]\n        //         ]\n        //     }\n        // }\n    ],\n\n    \"styles\": {\n        \"header\": {\n            \"fontSize\": 18,\n            \"bold\": true\n        },\n        \"subheader\": {\n            \"fontSize\": 15,\n            \"bold\": true\n        },\n        \"center\":\n        {\n            \"alignment\": \"center\"\n        }\n    }\n\n}\n\n//Add the contents - some parts will be conditionally added based on msg.options\n\n//header\ndocdef.content.push(\"\\n\\n\");\ndocdef.content.push({\n    \"text\": \"PDF Shift-Report\",\n //   \"text\":  msg.payload,\n    \"style\": \"header\"\n})\n\ndocdef.content.push(\"\\n\\n\");\ndocdef.content.push('\\n\\n'+ msg.payload+'\\n\\n');\n//docdef.content.push(\"\\n\");\n\n\n\nmsg.payload = docdef;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":930,"y":340,"wires":[["a5c5cba1e79c554d"]]},{"id":"a5c5cba1e79c554d","type":"pdfmake","z":"5e2273f4fb49e337","name":"","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":1160,"y":360,"wires":[["1179333b4da515bd"]]},{"id":"1179333b4da515bd","type":"string","z":"5e2273f4fb49e337","name":"","methods":[{"name":"getRightMost","params":[{"type":"str","value":"\\"}]}],"prop":"filename","propout":"file","object":"msg","objectout":"msg","x":1290,"y":360,"wires":[["de4dfde83f174195"]]},{"id":"de4dfde83f174195","type":"function","z":"5e2273f4fb49e337","name":"","func":"var now = new Date();\n// Create formatted time\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd  = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm  = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss  = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\n\n// file path with / at the end\nvar path = \"F:\\\\slip\\\\pdf\\\\\";                     // This is the path\n//var filename = filename+\".pdf\"; // file name\nvar filename = msg.file+\".pdf\"; // file name\n//var filename = \"cam3_\"+yyyy+mm+dd+\"-\"+hh+mm+ss+\".txt\"; // file name\nmsg.filename = path + filename;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1420,"y":360,"wires":[["7eba07998ca3e373"]]},{"id":"7eba07998ca3e373","type":"file","z":"5e2273f4fb49e337","name":"","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1580,"y":340,"wires":[[]]}]

this text file

Use the function I wrote for you...

[{"id":"e359c36aa00d7f17","type":"inject","z":"5e2273f4fb49e337","name":"/home/pi/logs","props":[{"p":"path","v":"/home/pi/logs","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":220,"wires":[["3d93ab7cae16d359","5d387a287fe54fad"]]},{"id":"3d93ab7cae16d359","type":"fs-ops-dir","z":"5e2273f4fb49e337","name":"get directory listing","path":"path","pathType":"msg","filter":"*.*","filterType":"str","dir":"payload","dirType":"msg","x":130,"y":280,"wires":[["17341aae0bdf6ee8"]]},{"id":"17341aae0bdf6ee8","type":"split","z":"5e2273f4fb49e337","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":290,"y":280,"wires":[["31485cf1e820b8b7"]]},{"id":"31485cf1e820b8b7","type":"function","z":"5e2273f4fb49e337","name":"create full path","func":"msg.file = msg.payload;\nmsg.filename = msg.path + \"/\" + msg.file;\n//msg.filename = msg.path ;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":280,"wires":[["407107c557a49f5c"]]},{"id":"407107c557a49f5c","type":"file in","z":"5e2273f4fb49e337","name":"","filename":"","format":"lines","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":620,"y":280,"wires":[["866d27f3fd41935b"]]},{"id":"91fa19a0c0711e29","type":"function","z":"5e2273f4fb49e337","name":"build document definition","func":"const content = [];\n\n//header\ncontent.push({\n    \"text\": \"PDF Shift-Report\",\n    \"style\": \"header\"\n})\ncontent.push(\"\\n\\n\");\n\n//Add the contents\ncontent.push(...msg.payload)\n\n//setup base document definition\nconst docdef = {\n    \"pageSize\": \"A4\",\n    \"pageOrientation\": \"portrait\",\n    \"pageMargins\": [\n        40,\n        60,\n        40,\n        60\n    ],\n    \"info\": {\n        \"title\": \"awesome Document\",\n        \"author\": \"john doe\",\n        \"subject\": \"subject of document\",\n        \"keywords\": \"keywords for document\"\n    },\n    \"content\": content,\n    \"styles\": {\n        \"header\": {\n            \"fontSize\": 18,\n            \"bold\": true\n        },\n        \"subheader\": {\n            \"fontSize\": 15,\n            \"bold\": true\n        },\n        \"center\":\n        {\n            \"alignment\": \"center\"\n        }\n    }\n\n}\n\nmsg.payload = docdef;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":280,"wires":[["e70e6ebc3ef6aa1c"]]},{"id":"e70e6ebc3ef6aa1c","type":"debug","z":"5e2273f4fb49e337","name":"To PDFMAKE --->>>","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1300,"y":320,"wires":[]},{"id":"f7f56017fae936dd","type":"function","z":"5e2273f4fb49e337","name":"reset/add/get","func":"const lines = context.get(\"lines\") || [];\nif(msg.topic === \"reset\") {\n    context.set(\"lines\", [])\n    node.status({fill:\"grey\",shape:\"dot\",text:\"\"});\n    return\n}\nif (msg.topic === \"get\") {\n    msg.payload = lines\n    node.status({ fill: \"green\", shape: \"dot\", text: `${lines.length} line(s) released` });\n    return msg\n}\n\nif (msg.topic === \"add\") {\n    const data = msg.payload.split(\"\\n\")\n    const filtered = data.filter(e => e.indexOf(\"{@RPT|\") >= 0)\n    if (filtered.length > 0) {\n        lines.push(...filtered.map(e => e.replace(\"{@RPT|\", \"\")))\n    }\n}\nnode.status({ fill:\"yellow\",shape:\"dot\",text:`${lines.length} line(s) ready to send`});\ncontext.set(\"lines\", lines)","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":970,"y":280,"wires":[["91fa19a0c0711e29","2dd99c41395ac3d5"]]},{"id":"0ebf7d1c3274656a","type":"switch","z":"5e2273f4fb49e337","name":"last one?","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"parts.count -1","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":1,"x":440,"y":340,"wires":[["f6ec90e56af11d2e"]]},{"id":"362f6c601931adc2","type":"change","z":"5e2273f4fb49e337","name":"get","rules":[{"t":"set","p":"topic","pt":"msg","to":"get","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":340,"wires":[["f7f56017fae936dd"]]},{"id":"5d387a287fe54fad","type":"change","z":"5e2273f4fb49e337","name":"reset","rules":[{"t":"set","p":"topic","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":220,"wires":[["f7f56017fae936dd"]]},{"id":"f6ec90e56af11d2e","type":"delay","z":"5e2273f4fb49e337","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":630,"y":340,"wires":[["362f6c601931adc2"]]},{"id":"866d27f3fd41935b","type":"change","z":"5e2273f4fb49e337","name":"add","rules":[{"t":"set","p":"topic","pt":"msg","to":"add","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":280,"wires":[["f7f56017fae936dd","0ebf7d1c3274656a"]]},{"id":"2dd99c41395ac3d5","type":"debug","z":"5e2273f4fb49e337","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1010,"y":240,"wires":[]}]