Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-jasperst

jmpevzla35MIT1.0.2TypeScript support: included

JasperReports for nodejs with JasperStarter

JasperReports, node, jasper, reports, JasperStarter

readme

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.

changelog

JasperStarter - Running JasperReports from command line

Release notes - JasperStarter - Version 3.5.0

** Bug

* [JAS-134] - "InterruptedException" should not be ignored in App.java
* [JAS-135] - comparisons between unrelated types in Config.java

** New Feature

* [JAS-131] - Jasperstarter does not provide a way to use the query string saved in the report itself

** Task

* [JAS-133] - Release Pipeline takes longer than before
* [JAS-136] - Throwable.printStackTrace(...) should not be called in Report.java setLookAndFeel()
* [JAS-137] - Do not use a bitwise operator with a Boolean-like operand in ParameterPanel.java
* [JAS-138] - Do not use a bitwise operator with a Boolean-like operand in ParameterPrompt.java

Release notes - JasperStarter - Version 3.4.1

** Bug

* [JAS-132] - Security alert on org.springframework:spring-core
              Updated springframework to 4.3.21

CVE-2016-5007 - moderate severity - Vulnerable versions: < 4.3.1
CVE-2018-1275 - high severity - Vulnerable versions: < 4.3.16
CVE-2018-1272 - moderate severity - Vulnerable versions: < 4.3.15
CVE-2018-1271 - moderate severity - Vulnerable versions: < 4.3.15
CVE-2018-1270 - high severity - Vulnerable versions: < 4.3.16
CVE-2018-1257 - moderate severity - Vulnerable versions: < 4.3.17

Release notes - JasperStarter - Version 3.4.0

JasperStarter-3.2.0 silently dropped Java7 support by using the latest available JasperReports Library. JasperReports-6.4.0 is the last release which works with Java7 so JasperStarter-3.1.0 was the latest release supporting Java7.

Now JasperStarter needs Java8 at a minimum and is manually tested with OpenJDK-8, OpenJDK-10, OpenJDK-11. Automatic testing is on the way (see JAS-128). There will be a special release supporting Java7.

"Diskless" operation using stdin and stdout for input data and output is now complete. See ([JAS-97] and [JAS-89]).

A public API allows direct integration with Python using jpy ([JAS-125]).

Known bugs:

* [JAS-120] - JasperReports-6.7.0 Version does not match with
              reported version from the jar file in
  This is an upstream error which causes JasperStarter to put out
  a wrong JasperReports version number of 6.6.0 instead of 6.7.0
  if you call: jasperstarter -V

** Bug

* [JAS-111] - JRE 1.7 incompatibility - not fixed in the main
              release but clarified.
* [JAS-122] - Runtime error if a chart with "chart customizers" is
              used
* [JAS-126] - Jasperstarter does not usefully propagate
              compilation errors

** New Feature

* [JAS-97] - Use stdout for the resulting PDF (so we don't have to
             write to the hosting server's storage)
* [JAS-125] - Make report fill accessible via API

** Task

* [JAS-127] - Enable dependency caching in build pipeline
* [JAS-129] - Remove test dependency to font Arial
* [JAS-130] - launch4j-maven-plugin:1.5.2 depends on 32bit
              libraries

Release notes - JasperStarter - Version 3.3.0

Known bugs:

* [JAS-120] - JasperReports-6.7.0 Version does not match with reported version from the jar file in 
  This is an upstream error which causes JasperStarter to put out
  a wrong JasperReports version number of 6.6.0 instead of 6.7.0
  if you call: jasperstarter -V

** Bug

* [JAS-116] - SSL error
* [JAS-121] - Container 'Build' exceeded memory limit.
* [JAS-122] - Runtime error if a chart with "chart customizers" is used

** New Feature

* [JAS-113] - JSONQL data source support

** Task

* [JAS-102] - Pipeline: enable build artifact upload to download section
* [JAS-119] - Include JasperReports-6.7.0

** Improvement

* [JAS-89] - Accept stdin for datafile input

Release Notes - JasperStarter - Version 3.2.1

** Task

* [JAS-109] - Include JasperReports-6.4.3

Release Notes - JasperStarter - Version 3.2.0

** Bug

* [JAS-96] - Enable JavaScript in expression
* [JAS-99] - jasperreports-functions not in maven central
* [JAS-100] - Pipeline build failed: Font "Arial" is not available to the JVM
* [JAS-101] - Pipeline build failed: net.sf.launch4j.ExecException: java.io.IOException: Cannot run program
* [JAS-107] - JasperStarter could not run reports with Barcode4J barcodes

** Task

* [JAS-108] - Include JasperReports 6.4.1

Release Notes - JasperStarter - Version 3.1.0

** New Feature

* [JAS-83] - JSON file as a data source

** Task

* [JAS-95] - Include JasperReports 6.4.0

** Improvement

* [JAS-84] - How to pass $P{XML_DATA_DOCUMENT} to sub report - additional documentation

Release Notes - JasperStarter - Version 3.0.0

This Release works with Java8.

** Bug

* [JAS-69] - Calls of assertEquals have the arguments actual and
             expected interchanged 
* [JAS-70] - Example report csv.jrxml truncates data 
* [JAS-80] - jasperstarter by default is missing some important
             jasper studio builtin libraries 
* [JAS-81] - Eclipse compiler error when running using Java 8

** Improvement

* [JAS-68] - Expand documentation with calls of running the
             example reports 

** New Feature

* [JAS-67] - Ability to produce CSV Metadata reports
* [JAS-72] - Ability to produce XLS Metadata reports

** Task

* [JAS-57] - Switching from Mercurial to Git
* [JAS-59] - Include JasperReports 6.0.0
* [JAS-61] - update dependencies
* [JAS-65] - Include JasperReports 6.0.2
* [JAS-66] - Include JasperReports 6.0.3
* [JAS-76] - Git version and revision information in manifest file
* [JAS-79] - Include JasperReports 6.0.4

Release Notes - JasperStarter - Version 2.2.2

** Bug

* [JAS-63] - Version 2.2 WindowsSetup replace the path variable

Release Notes - JasperStarter - Version 2.2.1

** Bug

* [JAS-58] - DB type generic should not require a username
* [JAS-62] - Linux startup script does not work if called via symlink

** Task

* [JAS-57] - Switching from Mercurial to Git (Branch Jasperstarter-2.2)

Release Notes - JasperStarter - Version 2.2.0

** Bug

* [JAS-54] - Eclipse complains: Plugin execution not covered by
             lifecycle configuration

** New Feature

* [JAS-56] - Support for XML data sources

** Task

* [JAS-48] - Rewrite api calls deprecated since JasperReports 5.6.0
* [JAS-49] - Rewrite code reported by -Xlint:unchecked

Release Notes - JasperStarter - Version 2.1.2

** Bug

* [JAS-53] - Property net.sf.jasperreports.export.xls.one.page.per.sheet was overrided

Release Notes - JasperStarter - Version 2.1.1

** Task

* [JAS-52] - Include JasperReports 5.6.1

Release Notes - JasperStarter - Version 2.1.0

** Bug

* [JAS-40] - No page title is set in index.html

** New Feature

* [JAS-50] - Accept number of copies when printing

** Task

* [JAS-47] - Include JasperReports 5.6.0

Release Notes - JasperStarter - Version 2.0.0

The command line syntax has changed in this release! <input> is now an argument and the format of report parameters has changed. Specifying the parameter type is no longer necessary. The type is determined from the report and it is no longer possible to provide a non existent parameter. The major new feature is support for csv files as a datasource.

** Bug

* [JAS-37] - The artifact org.apache.commons:commons-io:jar:1.3.2 has been
             relocated to commons-io:commons-io:jar:1.3.2
* [JAS-41] - Command "jasperstarter params" gives no useful result if param
             has no description

** Improvement

* [JAS-15] - Report parameters should be handled in a more generic way
* [JAS-42] - Accept <input> as positional argument instead of an option

** New Feature

* [JAS-30] - CSV as a datasource for Jasperstarter

** Task

* [JAS-23] - create unit test
* [JAS-24] - create example reports
* [JAS-34] - site translation de for release 2.0
* [JAS-35] - site translation cz for release 2.0
* [JAS-38] - Update build dependencies
* [JAS-39] - Include JasperReports 5.2.0

Release Notes - JasperStarter - Version 1.4.2

** Bug

* [JAS-41] - Command "jasperstarter params" gives no useful result
             if param has no description 

Release Notes - JasperStarter - Version 1.4.1

** Bug

* [JAS-33] - Report parameter with space produces error on Unix
             like systems

Release Notes - JasperStarter - Version 1.4.0

** Bug

* [JAS-29] - Documentation typo java.awt.image

** Task

* [JAS-31] - Include JasperReports 5.1.2
* [JAS-32] - Include argparse4j 0.4.1

Release Notes - JasperStarter - Version 1.3.0

This release is mainly due to the new JasperReports library version 5.1.0.

** Improvement

* [JAS-28] - Include argparse4j 0.4.0 which introduces some features to the
             user
             - Argument abbreviations
             - Subcommand abbreviations

** Task

* [JAS-27] - Include JasperReports 5.1.0

Release Notes - JasperStarter - Version 1.2.0

This release is mainly due to the new JasperReports library version 5.0.4.

** Improvement

* [JAS-25] - Implement command aliases

** Task

* [JAS-19] - create an independent configuration bean as replacement for the
             parser dependend namspace object
* [JAS-20] - move any call of System.exit() to App.main()
* [JAS-21] - remove obsolete option --keep
* [JAS-26] - Use jasperreports library 5.0.4

Release Notes - JasperStarter - Version 1.1.0

JasperStarter is now able to prompt for report parameters.

** Bug

* [JAS-5] - Maven site does not create index.html if called directly
* [JAS-6] - Maven site does not generate translation if called directly
* [JAS-11] - Maven site does not create index.html if called via package
* [JAS-16] - Selection of the report locale yields unexpected results in
             some cases

** Improvement

* [JAS-13] - new parameter type locale to specify report locale independent
             from gui locale

** New Feature

* [JAS-12] - new option to specify report resources like resource bundles or
             icons
* [JAS-14] - New option: prompt for report parameters
* [JAS-17] - New Command: List report parameters

** Task

* [JAS-7] - Site translation cs
* [JAS-22] - site translation de

1.0.1 [JAS-18] - Unable to save output into Excel format

1.0.0 JasperStarter now has commands: pr - process, lp - list printers. New command: cp - compile, can compile one file or all .jrxml in a directory. New input file types for command pr allowed: jrxml - compiles implicit jrprint - print, view or export previously filled reports. New output type: jrprint. This makes --keep obsolete. New parameter -w writes compiled file to imput dir if jrxml is processed. Parameter -t defaults to "none" and can therefore be omited if no database is needed. Input file is read once. No temporary files needed anymore. Setup checks for previous versions and creates menuitems for uninstall and help. Setup is available in English, Chinese (Simplified), Czech, French, Hungarian, German, Polish, Romanian, Thai, Ukrainian. [JAS-2] - runtime parameter value cannot contain equal sign Contains JasperReports 5.0.1 German translation for Site/docs [JAS-4] - java.lang.Integer cannot be cast to java.lang.String [JAS-8] - java.lang.String cannot be cast to java.lang.Integer [JAS-9] - Exception in thread "main" java.lang.IllegalArgumentException: URI has an authority component

0.10.0 New report parameter types: double, image (see usage). New supported export formats: xls, xlsx, csv, ods, pptx, xhtml, xml. Windows setup available. --version shows included JasperReports version. Fixed some minor bugs.

V 0.9.1 Bugfix release fixed problems with --jdbc-dir option.

V 0.9.0 First public release Switched from Commons CLI to argparse4j. Project documentation in generated site. README uses markdown syntay, renamed to README.md. Applied Apache License 2.0 to the software. JasperStarter now starts via executable files in ./bin. Windows binary jasperstarter.exe is generated with launch4j.

V 0.8.0 Switched to maven.

V 0.7.1 Fixed issue: duplicated option -n

V 0.7.0 new option --set-report-name to temporary change the reportname when printing. This is useful if you want to change the printjob name for printing to a pdf printer like cups-pfd which uses the document name as part of the pdf name by default.

V 0.6.0 new options --printer-name --with-print-dialog --list-printers printername matches .toLowercase().startWith() and spaces can be escaped by the underline character _. print dialog and viewer appear in system look an feel.

V 0.5.0 support for postgres, oracle and generic jdbc password is no longer a required option except for oracle jrprint file is stored in system temp dir and deleted after processing new options --jdbc-dir, --debug, --keep-jrprint file extension .jasper is added to input if omitted output can be omitted or can be file or directory

V 0.4.0 jdbc drivers are loaded from jdbc dir new parameter: db-type: none, mysql (none provides JREmptyDataSource() for a non database report) support for barcode4j

V 0.3.1 Bugfix: removed jasperreports-javaflow added barbecue barcode lib

V 0.3.0 Print preview nicer help message package renamed

V 0.2.0 Print support added Added exportformats html, odt Added report parameter type date. New parameter db-name - database name

V 0.1.0 First working version Supports export to PDF, DOCX, RTF. Simple report parameters of type string and int.