Open joseespinozac opened 4 years ago
look in my tested content for sample js: var fs = require('fs');
var jasper = require('node-jasper')({ path: '../lib/jasperreports-5.6.0', reports: { stock_ofertas: { jasper: dirname + '/sample.jasper', jrxml: dirname + '/sample.jrxml', conn: 'in_memory_json' } } });
jasper.ready(function() { var r = jasper.export( { report: 'stock_ofertas', data: { language: 'spanish', // on jasper make a parameter named "dataset2" and use on a subreport: // ((net.sf.jasperreports.engine.data.JsonDataSource)$P{dataset2}) dataset2: jasper.toJsonDataSource( { dados: [{ value: 1, value: 2 }] }, 'dados' ) }, dataset: [ { name: 'Gonzalo', lastname: 'Vinas' // TODO: check on UTF-8 }, { name: 'Agustin', lastname: 'Moyano' } ] }, 'pdf' );
//fs.writeFile(__dirname + '/sample.pdf', r);
fs.writeFile(__dirname+ '/sample.pdf', r, (error)=>{
if(error) console.log(error);
})
});
Why you want build an json from an array? If you want do this, then look for tools which are build the json from an array.
I would love a more detailed example on how to use or declare the dataset in the report JSON
Sorry for my english And please tell me if I can send arrays? and how to do it