1.0.2 • Published 12 months ago

node-jasperst v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Node-JasperSt

Based on PHPJasper Lib

A NodeJS Report Generator

About

Node-JasperSt is the best solution to compile and process JasperReports (.jrxml & .jasper files) just using nodejs, in short: to generate reports using nodejs.

Why Node-JasperSt?

Did you ever had to create a good looking Invoice with a lot of fields for your great web app?

I had to, and the solutions out there were not perfect. Generating HTML + CSS to make a PDF? That doesn't make any sense! :)

Then I found JasperReports the best open source solution for reporting.

What can I do with this?

Well, everything. JasperReports is a powerful tool for reporting and BI.

From their website:

The JasperReports Library is the world's most popular open source reporting engine. It is entirely written in Java and it is able to use data coming from any kind of data source and produce pixel-perfect documents that can be viewed, printed or exported in a variety of document formats including HTML, PDF, Excel, OpenOffice and Word.

It is recommended using Jaspersoft Studio to build your reports, connect it to your datasource (ex: MySQL, POSTGRES), loop thru the results and output it to PDF, XLS, DOC, RTF, ODF, etc.

Some examples of what you can do:

  • Invoices
  • Reports
  • Listings

Requirements

  • NodeJS 14 or above
  • Java JDK 1.8

Optional

Installation

Just run:

npm install node-jasperst

You should have installed dotenv for config Java Runtime Enviroment 8 (JRE) path

npm install dotenv

Examples

  • in src/demo.ts you can see some examples:
import { NodeJasperSt } from 'node-jasperst'
import * as dotenv from 'dotenv'
import path from 'path';
dotenv.config()

enum reports {
  Hello = "examples/hello_world.jrxml",
  Contactos = "examples/json.jrxml",
}

enum data {
  Contactos = 'contacts.json',
}

const output = 'output';

async function compileJasper(njst: NodeJasperSt) {
  await njst.compile(reports.Contactos, output);
  result = await njst.execute()
  console.log(result)
}

async function processJasper(njst: NodeJasperSt) {
  let result = ''
  njst.process(reports.Contactos, output, {
    db_connection: {
      'driver': 'json',
      'data_file': path.join('examples', data.Contactos), 
    }
  });
  
  result = await njst.execute()
  console.log(result)
}

async function init() {
  const njst = new NodeJasperSt()
  await compileJasper(njst);
  await processJasper(njst);
}
init();
  • for more examples, please see PHPJasper README.md Examples.
1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago