app.get('/documents/:var', function(req, res,next) {
exporter.export(exportSettings, function (err, resd) {
if(resd){var svg_to_png = require('svg-to-png');
svg_to_png.convert(resd.data, imagedata) // async, returns promise
.then( function(){fs.writeFile('logos.png', imagedata, 'binary', function(err){
if (err) throw err
console.log('File saved.')
res.sendFile(logos.png)
})
// Do tons of stuff
});
console.log(resd)
var imagedata
// var base64Data = imagedata.replace(/^data:image\/png;base64,/, "");
;}
//The export result is now in res.
//If the output is not PDF or SVG, it will be base64 encoded (res.data).
//If the output is a PDF or SVG, it will contain a filename (res.filename).
//Kill the pool when we're done with it, and exit the application
// exporter.killPool();
// process.exit(1);
});})
Im trying to build a route that writes graphs, into a file and send it to frontend
but i tried all day with different methods.
Anibody know this stuff?
I can console.log resd.data its an object { data: 'omfepf4294jr44'}
but when i try save it on server for testing the image is unreadable.