jasper_nodejs
v1.0.20
Published
wrapper jasper report untuk nodejs
Maintainers
Readme
jasper_nodejs
Generate JasperReports from Node.js using JasperStarter / jasper binary.
✨ Features
- Compile
.jrxmlto.jasper - Export report to PDF / HTML / XLS / etc
- Support parameters
- Support database connection (Postgresql, Mysql)
- Works with pure Node.js or frameworks (AdonisJS, Express, etc)
☕ Java Requirement
This package requires Java (JRE or JDK) to be installed.
Supported Versions
- Java 8
Check Java installation
java -version🐧 Java Linux Installation (Ubuntu / Debian)
Install Java
sudo apt update
sudo apt -y install openjdk-8-jdk🪟 Java Windows Installation
Install Java
https://www.java.com/en/download/manual.jsp
📦 Installation
npm install jasper_nodejsContoh penggunaan:
import ReportService from "jasper_nodejs";
const reportService = new ReportService();
const outputDir = app.makePath("tmp/reports"); // specify the directory where the generated report files will be saved (app.makepath is adonisjs)
// Pastikan folder ada
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
try {
const outputFile = await reportService.export({
reportFile: app.makePath("resources/reports/jadwal.jasper"), // you may use the .jrxml extension; the .jasper file is generated by compiling the .jrxml template
outputDir: outputDir,
format: "pdf", // e.g view, print, pdf, rtf, xls, xlsMeta, xlsx, docx, odt, ods, pptx, csv, csvMeta, html, xhtml, xml, jrprint
params: {
idproduct: 3, // Parameters defined here will be forwarded to Jasper reports and can be accessed using $P{idproduct}.
},
db: {
dbname: "your_database_name", // e.g. postgres
host: "your_database_host", // e.g. localhost
driver: "postgres", // e.g postgres, mysql
port: "your_database_port", // e.g default PostgreSQL port 5433
username: "your_database_user", // e.g. postgres
password: "your_database_password",
},
});
} catch (error) {
console.log(error);
}