Hi guys,
I'm trying to generate a pdf from an html template and get it via api url.
So I use pdfmake and I generate the pdf of the example (I rename the pdf bordero.pdf).
[
{
"id": "ba55707c1c8a4554",
"type": "pdfmake",
"z": "bba181f313928b6c",
"name": "",
"outputType": "Buffer",
"inputProperty": "payload",
"options": "{}",
"outputProperty": "payload",
"x": 500,
"y": 820,
"wires": [
[
"b1510b53716a05c8"
]
]
},
{
"id": "6165da421edf2ca3",
"type": "inject",
"z": "bba181f313928b6c",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"content\":[\"First paragraph\",\"Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines\"]}",
"payloadType": "json",
"x": 330,
"y": 820,
"wires": [
[
"ba55707c1c8a4554"
]
]
},
{
"id": "b1510b53716a05c8",
"type": "file",
"z": "bba181f313928b6c",
"name": "",
"filename": "bordero.pdf",
"appendNewline": true,
"createDir": false,
"overwriteFile": "true",
"encoding": "none",
"x": 690,
"y": 820,
"wires": [
[]
]
},
{
"id": "d0615b28b4dcf66e",
"type": "comment",
"z": "bba181f313928b6c",
"name": "Simple Example PDF",
"info": "This is the simplest PDF test as seen in the pdfmake examples [here](http://pdfmake.org/playground.html)",
"x": 380,
"y": 780,
"wires": []
}
]
and after I expose the file creating a get endpoint MYNODERED/bordero.pdf:
[
{
"id": "26de497f9ebb6e55",
"type": "http in",
"z": "bba181f313928b6c",
"name": "",
"url": "/bordero.pdf",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 140,
"y": 440,
"wires": [
[
"061fc71f38cab67e"
]
]
},
{
"id": "061fc71f38cab67e",
"type": "file in",
"z": "bba181f313928b6c",
"name": "",
"filename": "bordero.pdf",
"format": "utf8",
"chunk": false,
"sendError": false,
"encoding": "none",
"allProps": false,
"x": 390,
"y": 440,
"wires": [
[
"163eec4dba8ab5f7"
]
]
},
{
"id": "163eec4dba8ab5f7",
"type": "http response",
"z": "bba181f313928b6c",
"name": "",
"statusCode": "",
"headers": {},
"x": 590,
"y": 440,
"wires": []
}
]
In the frontend I get the pdf stream and I open it in a new window but it is blank.
If I try to change the direction of the page (from portrait to landscape for example) I can see the uptade but the content still white.
This is how I get the stream:
const bordero = await axios({
url: `MYENDPOINT/bordero.pdf`,
method: "GET",
responseType: "blob",
}).then(({ data }) => data);
const file = new Blob([bordero], { type: "application/pdf" });
const fileURL = URL.createObjectURL(file);
window.open(fileURL);
I try in to different nodered implementation and the result is the same.
Did you have any advice?
Thanks in advance and kind regards,
Davide