Just to calrify ... are you using the PDFMake node node-red-contrib-pdfmake ?
if yes .. i dont think there is a need to make the msg.payload
into a JSON string
but you have to structure your sqlite db's output msg to be in the table structure the pdfmake node expects.
Here is a demo flow of how to make a table :
[{"id":"f8a7f83d80d07ff5","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":3960,"wires":[["924e9713d93837d6"]]},{"id":"924e9713d93837d6","type":"function","z":"54efb553244c241f","name":"fake data","func":"\nmsg.payload = {\n content: [\n\n { text: 'This is my Sqlite Table:', fontSize: 14, bold: true, margin: [0, 20, 0, 8] },\n {\n style: 'tableExample',\n table: {\n headerRows: 1,\n body: [\n [{ text: 'Header 1', style: 'tableHeader' }, { text: 'Header 2', style: 'tableHeader' }, { text: 'Header 3', style: 'tableHeader' }],\n ['Sample value 1', 'Sample value 2', 'Sample value 3'],\n ['Sample value 1', 'Sample value 2', 'Sample value 3'],\n ['Sample value 1', 'Sample value 2', 'Sample value 3'],\n ['Sample value 1', 'Sample value 2', 'Sample value 3'],\n ['Sample value 1', 'Sample value 2', 'Sample value 3'],\n ]\n },\n layout: 'lightHorizontalLines'\n },\n\n ],\n styles: {\n header: {\n fontSize: 18,\n bold: true,\n margin: [0, 0, 0, 10]\n },\n subheader: {\n fontSize: 16,\n bold: true,\n margin: [0, 10, 0, 5]\n },\n tableExample: {\n margin: [0, 5, 0, 15]\n },\n tableHeader: {\n bold: true,\n fontSize: 13,\n color: 'black'\n }\n },\n defaultStyle: {\n // alignment: 'justify'\n }\n\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":3960,"wires":[["2c4abf85948ac92c"]]},{"id":"2c4abf85948ac92c","type":"pdfmake","z":"54efb553244c241f","name":"","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":640,"y":3960,"wires":[["3f2acb163d057cda"]]},{"id":"3f2acb163d057cda","type":"file","z":"54efb553244c241f","name":"","filename":"c:/share/pdfTest.pdf","filenameType":"str","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":840,"y":3960,"wires":[[]]}]
if you need help restructuring the db data, then send us a sample msg of a few rows to play with