Reputation: 1
I am using Highcharts Node.js Export Server module in my nodejs application.
I want to get the response as SVG string rather than generating the SVG file on the server. Is it possible to get the SVG String as response.
I am using the latest Highcharts Node.js Export Server module . I can get the base64 encoded data in res.data but i cannot see any ways to get the SVG string as response.
I am using below snippet to call the exporter module :
exporter.initPool();
exporter.export(exportSettings, function (err, res) {
exporter.killPool();
process.exit(1);
});
I want to get the response as SVG string like " ........"
Upvotes: 0
Views: 570
Reputation: 7372
Unfortunately, it is not possible to get a response as an SVG string instead of the file. However, it can be achieved by reading the file returned by the export callback. Optionally after this operation, the file can be removed.
Code:
exporter.export(exportSettings, function(err, res) {
if (res.filename) {
let svgString = fs.readFileSync(res.filename, 'utf8');
console.log(svgString);
// Remove the file optionally
fs.unlinkSync(res.filename);
}
exporter.killPool();
process.exit(1);
});
Upvotes: 1