Report Manager ← Back to site

Report Manager in JavaScript: the npm packages

Esta página en español

The @reportman/* packages on npm are the Report Manager engine written in JavaScript: they open a .rep report, lay it out and write its PDF with no native binaries, no WebAssembly, no Docker and no operating-system dependencies. They run in Node.js and in the browser, and they are a translation of the .NET engine of the same release: the two are meant to give the same output for the same report.

Preview. This is the 4.1.0 preview, published under the npm tag next (npm install @reportman/node@next). The API may still change before the final 4.1.0, so pin the exact version you install if you build on it now.

Requirements

Node 22.12 or later. The packages are ES modules and there is no CommonJS build; a CommonJS program loads them with require(), which Node supports for ES modules. In the browser they need no bundler plugin: they are plain JavaScript.

The two steps: describe the parameters, then run

A report is run in two steps, as in the other engines. First you ask it what parameters it has, so your program (or your user) can fill them in; then you run it with their values. The host gives the engine the report bytes, the data access and the fonts — the engine itself does no I/O.

import { writeFileSync } from 'node:fs';
import { openReport, sqlite } from '@reportman/node';

const report = await openReport('invoices.rep', {
  connections: { SAMPLES: sqlite('samples.db') },
  fonts: {}, // the TrueType fonts of the system; without it, the 14 standard PDF fonts
});

// Step 1: what the report asks for
console.log(await report.describeParameters());

// Step 2: run it with their values
writeFileSync('invoices.pdf', await report.executeToPdf({ FIRST_ORDER: 7, LAST_ORDER: 9 }));

From the command line, and without writing code

@reportman/node installs reportman-pdf, which does the same two steps from a shell:

npm install @reportman/node@next
npx reportman-pdf invoices.rep --describe --sqlite SAMPLES=samples.db
npx reportman-pdf invoices.rep -o invoices.pdf --sqlite SAMPLES=samples.db -paramFIRST_ORDER=7 -paramLAST_ORDER=9

And to see the sample reports running without installing anything or writing a line of code, @reportman/server serves them with its own console and API explorer:

npx @reportman/server --samples

It writes the samples and their database into ./reportman-data, prints the console key and listens on http://127.0.0.1:8080/. The explorer runs each sample to PDF, metafile, text or CSV, and shows the same call for curl, PowerShell, JavaScript, C# and Delphi.

That server speaks the same API as Reportman Server and reads the same data folder, but it does not design reports: see the four Report Manager servers side by side.

Databases

The engine reads its data through a driver package, one per backend, with the same behaviour as the .NET providers. Install the one you need next to @reportman/node:

DatabasePackage
PostgreSQL@reportman/driver-postgres
MySQL and MariaDB@reportman/driver-mysql
Microsoft SQL Server@reportman/driver-mssql
Firebird@reportman/driver-firebird
Reportman DB Agent, through the Hub@reportman/driver-http

SQLite needs no driver: @reportman/node reads it with Node's own node:sqlite. The Agent driver is the only one that also works in the browser, because it talks HTTP to the Reportman DB Agent through the Hub instead of opening a database connection itself.

Reports saved as XML, and reports saved as DFM

As in the .NET engine, the readers take XML .rep files, plain or compressed, and those need nothing extra. A report that Delphi saved in a DFM form needs the optional @reportman/dfm package, which converts it to the XML Delphi writes for it; @reportman/node uses it on its own when it is installed. The other way out is to save the report again as XML, from the designer or with reptotxt -xml.

Try it, and the reference

The report files are the same ones the Delphi and .NET designers open, so a report designed with either of them runs here unchanged. See also the .NET library and the command line tools.