JasperReports for NodeJS
npm install jaspernode -S
'use strict'
const Helpers = use('Helpers')
const JasperNode = require('jaspernode')
class JasperController {
async jasper ({ response }) {
const jasper = new JasperNode(Helpers.appRoot('tmp/JasperNode'))
let inputFile = Helpers.appRoot('tmp/JasperNode/params.jasper')
let outputFile = Helpers.appRoot('tmp/JasperNode/output')
let parameters = {
myString: jasper.quotes('My String'),
myInt: 100,
myImage: jasper.quotes('sample.jpg')
}
try {
const pathFile = await jasper.process(inputFile, outputFile, parameters).execute()
return response.send(pathFile)
} catch (e) {
return response.send(e)
}
}
}
npm test
npm run cover
- Thanks to Cenote GmbH for the JasperStarter tool.
- Thanks to Hélder Duarte for the JasperPHP repository
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.