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":[]}]