Can't figure out what to do with the base64 encoded data. Found this related thread, and I have tried the same actions, but I get the same result as that user. Any suggestions on how to get the pdf from this base64 encoded format to a downloadable PDF?
Posts made by engern
-
RE: Azure function and client js
-
RE: Azure function and client js
Thanks, yes I followed that one.
I will look into it tomorrow. Guess I can use the code sample until the fs.createWriteStream part, because that wont be possible in the browser/client...
-
Azure function and client js
Hello
I followed the guide on setting up jsreport as an Azure function, and my template shows as expected on https://jsreporttest-abacus.azurewebsites.net/api/report
Now I try to get it from the client, and I have tried both browser.js and node.js without any luck.
browser.jsconst jsreport = require('jsreport-browser-client-dist') jsreport.serverUrl = "https://jsreporttest-abacus.azurewebsites.net"; var request = { template: { shortid: 'oizlGafQAt', recipe: 'chrome-pdf' }, data : { to: "To", from: "From", price:"200" } }; jsreport.render('_blank', request);
This gives the error in the browser: "Template must contains _id, shortid or content attribute.....(stacktrace)" (I have tried to use content instead of shortid as well, but still the same error)
node.js
const jsreport = require("jsreport-client")("https://jsreporttest-abacus.azurewebsites.net"); const res = await jsreport.render({ template: { shortid: 'oizlGafQAt', recipe: 'html', engine: 'handlebars' }, data : { to: "To", from: "From", price:"200" } }) const bodyBuffer = await res.body() console.log(bodyBuffer.toString())
Gives the error in the console: "XML Parsing Error: junk after document element" (but I se in the Network tab that it actually generates the HTML in the response correctly) If I switch to receipe: chrome-pdf it gives : "XML Parsing Error: not well-formed"
What am I doing wrong here?