Skip to content

ahmadarif/JasperNode

Repository files navigation

JasperNode

npm version npm build status Coverage Status npm contributions

JasperReports for NodeJS

Requirements

  • Java is already installed on your machine
  • NodeJS 8.0 or greater
  • NPM 3.0 or greater

Installation

npm install jaspernode -S

Usage (in AdonisJS)

'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)
        }
    }
}

Tests

npm test

Code Coverage

npm run cover

Thanks

Contributing

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.