Documentation
ferroreport takes a template (JasperReports' .jrxml, or its own .ferro), your rows
as JSON and your parameters, and returns a PDF, an Excel workbook, a Word document, a PowerPoint presentation, an OpenDocument file, a CSV file or an HTML preview. Every way of calling it, from the command line to Python, uses the same engine and produces the same bytes.
Your first PDF
You need three files: the template you designed in Jaspersoft Studio, the rows, and the parameters.
ferroreport render invoice.jrxml --data rows.json --params params.json -o invoice.pdf
# rows.json: one object per detail row; keys are the template's <field> names
[
{ "sku": "FX-1000", "description": "Hydraulic pump 2HP", "qty": 21, "price": "185.00" },
{ "sku": "FX-1007", "description": "Stainless steel valve", "qty": 26, "price": "42.50" }
]
# params.json: one key per <parameter>
{ "CUSTOMER": "Distribuidora Caribe, S.A.", "ISSUED": "2026-03-05", "TAX_RATE": "0.18" }
The same render from code:
// JavaScript
import { render } from "ferroreport";
const pdf = render(jrxml, rows, params, { locale: "es_DO" });
# Python
import ferroreport
pdf = ferroreport.render("invoice.jrxml", rows, params, locale="es_DO")
# Any language, over HTTP
curl -X POST localhost:8080/render/invoice -H 'Content-Type: application/json' \
-d '{"data": [...], "params": {...}, "locale": "es_DO"}' -o invoice.pdf
Install
| You use | Install |
|---|---|
| Command line | Download the binary for Linux, macOS or Windows from GitHub Releases, or cargo install ferroreport-cli |
| Docker, HTTP | docker pull ghcr.io/cristianencarnacion/ferroreport |
| JavaScript | npm install ferroreport |
| Python | pip install ferroreport |
| Rust | cargo add ferroreport |
The npm package, the Rust crates, the binaries and the Docker image are available now. The PyPI package is being published.
Template, data, parameters
Template
The JRXML source, exactly as Jaspersoft Studio saves it (JRXML 6, and JRXML 7 as JasperReports 7 writes it), or a
.ferro template: every function that takes a template takes either. Compiled .jasper files are
never loaded: if a template names lines.jasper, ferroreport reads lines.jrxml (or lines.ferro) instead.
Data
A JSON array with one object per row, or one JSON object per line (JSON Lines). Keys match the <field name="..."> entries; a field named
customer.name reads {"customer": {"name": ...}}. A missing key or null gives a null field.
Each value is converted to the class the field declares:
| Field class | JSON you send |
|---|---|
String | A string (other values are written as text) |
Integer, Long, Double, Float | A number, or a numeric string |
BigDecimal | A number or a string. Use a string such as "185.00" to keep the exact digits |
Boolean | true / false, or "true" |
Date, Timestamp, Time | ISO-8601 text ("2026-03-05", "2026-03-05T10:30:00", with or without offset) or epoch milliseconds |
byte[] (images) | Base64 text or a data: URI |
List, Collection | A nested array, usually the rows of a subreport |
Reports without a data source can omit the data. A template's SQL query runs on the database given with --db (see Rows from a database); without it, send the rows.
Parameters
A JSON object with one key per <parameter>, converted with the same rules. Parameters you leave out take
their defaultValueExpression.
Templates in .ferro
.ferro is ferroreport's own template format: the same reports as JRXML, written as an indented outline instead of
XML. It is about half the size, a person can write it without a designer, and its reports are accessible by default.
// Employees, with their salaries and the total.
report "Employees" lang=en
style Base default fontName="DejaVu Sans" size=10
field salary Double
variable total Double calculation=Sum : {salary}
title 40
h1 0,0 555x30 size=18 : Employees
columnHeader 20
text 0,0 300x20 bold : Name
text 300,0 255x20 bold align=right : Salary
detail 20
text 0,0 300x20 : {name}
text 300,0 255x20 pattern=#,##0.00 align=right : {salary}
image 0,0 20x20 alt="Photo of the employee" : {photo}
summary 20
text 300,0 255x20 bold align=right : Total: $V{total}
| Part of a line | Meaning |
|---|---|
| The first word | What the line is: report, style, field, a band
(title, detail, pageFooter...), a part (text, image,
line, rectangle, frame, subreport, chart,
crosstab, component...), or any other JRXML 7 element by its name (box,
pen, property...) |
| Indentation | A line indented under another is inside it |
x,y and widthxheight | A part's position and size, in points |
| A number after a band | Its height. detail 20 is a detail section with one band 20 points tall (the same for
groupHeader and groupFooter) |
name=value | An attribute. Quote the value when it has spaces: pattern="MMMM d, yyyy".
A name alone means true: bold. color=, background=,
align=, valign= and size= are short for the JRXML names (below); any other JRXML 7
attribute is written with its own name |
: text | The text of a text part, or the expression of the line: an image's, a
variable's or group's expression, a parameter's default value, the condition of if |
{name} | The value of the field name of the current row, in a text or in any expression.
$P{name} is a parameter, $V{name} a variable ($V{PAGE_NUMBER}...) |
Words after field, parameter, variable | The name and the class:
field amount BigDecimal. String, Integer, Long, Double,
BigDecimal, Boolean, Date, Timestamp, List... need no package.
style, group and property take their name the same way |
A line ending in : | The text is on the lines below, one level further in, as written (for long
expressions and texts of several lines). := "..." gives it as a JSON string |
report options | page=A4 (or A3, A5, Letter,
Legal, 612x792), landscape, margins=20 (or 20,30, or four
numbers), lang=es-DO, tagged=false. Without them a report is A4, portrait, with 20-point margins |
// ... | A comment |
Texts and fields
A text is printed as written, unless it has holes: {name} (a field), $P{name},
$V{name} or $R{key} are filled in from the data.
| Write | And you get |
|---|---|
text : Overdue | The text, as it is. Braces that are not a name stay too: {0}, {a b} |
text : Invoice {number} · {customer} | The text with the values in it |
text pattern=#,##0.00 : {total} | The value alone, as a number (or date) that pattern= formats |
text : ={qty} * {price} | A text that starts with = is an expression, as in a spreadsheet |
text : \{not a hole\} costs \$5 | \{, \}, \$, \= and
\\ print the character itself |
Fields need no declaration. A field written as {name} that has no field line is declared
for you, in the report or in the each it is used in, with class Object: its values keep the type
the data gives them (text, number, true or false, a list). Declare a field to give it a class: dates, which arrive as text,
need field due Date before pattern= can format them, and JasperReports needs the class of a
field used in arithmetic or in a condition to compile the JRXML. $F{name} still needs its declaration.
Long forms also work
Every short form is written as the JRXML of its long form, JasperReports' own names, which also work and can be mixed with them:
| Short form | Also works |
|---|---|
text : Total | staticText : Total |
text : Invoice {number} | textField : "Invoice " + $F{number} |
text : {total}, text : ={qty} * {price} | textField : $F{total},
textField : $F{qty} * $F{price} |
{name} in an expression | $F{name} |
No field line for {name} | field name Object |
color=red | forecolor=#FF0000. Colors by name are those JasperReports knows:
black, white, gray (or grey), lightGray,
darkGray, red, green, blue, yellow, orange,
pink, cyan, magenta; or #RRGGBB |
background=#EEEEEE | backcolor=#EEEEEE mode=Opaque (a background shows only on an
opaque part; mode= on the line wins) |
align=left, center, right, justify | hTextAlign=Left,
Center, Right, Justified (on an image, hImageAlign=) |
valign=top, middle, bottom | vTextAlign=Top, Middle,
Bottom (on an image, vImageAlign=) |
size=12 on a text or a style | fontSize=12 |
When a line gives both names (color= and forecolor=), the JRXML one is used. In a report with
language=groovy (or javascript), braces in expressions belong to the language and are left alone:
write $F{name} there (the holes of a text still work). The first example in long forms gives the
same JRXML:
report "Employees" lang=en
style Base default fontName="DejaVu Sans" fontSize=10
field salary Double
field name Object
field photo Object
variable total Double calculation=Sum : $F{salary}
title 40
h1 0,0 555x30 fontSize=18 : Employees
columnHeader 20
staticText 0,0 300x20 bold : Name
staticText 300,0 255x20 bold hTextAlign=Right : Salary
detail 20
textField 0,0 300x20 : $F{name}
textField 300,0 255x20 pattern=#,##0.00 hTextAlign=Right : $F{salary}
image 0,0 20x20 alt="Photo of the employee" : $F{photo}
summary 20
textField 300,0 255x20 bold hTextAlign=Right : "Total: " + $V{total}
Accessible by default. A .ferro report gives a tagged PDF, the kind screen readers
follow, unless it says tagged=false, in the language of lang= (or of the locale). h1 to
h6 are headings (a static text tagged as one), alt="..." describes an image, and tag=th
(or td, table, h2...) says what any element is.
Without coordinates
Positions and sizes can be left out, and ferroreport works them out:
report "Employees" lang=en
field salary Double
def money value
text pattern=#,##0.00 align=right : {{value}}
title gap=6
h1 height=30 size=18 : Employees
text height=14 color=gray : Everyone on the payroll
detail
row height=16
text 3fr : {name}
use money 1fr value={salary}
| Write | And you get |
|---|---|
Parts without x,y | One under the other, as wide as the band (or frame); the band is as tall as they need unless it gives a height |
row | Its parts side by side. Each says its width: points (100), a share of the row (40%) or a fraction of what is left (2fr, 1fr; a part with no width is 1fr). height= sets the height of its parts |
stack | Parts one under another inside a row |
gap= | On a band, frame, row or stack: the space between its parts, in points (4 unless you say) |
def name params... | A definition: the parts under it, with {{param}} where a value goes |
use name param=value | The definition's parts, with the values in place. A width (1fr) and other attributes on use go to its parts |
if : {overdue} | Its parts print only when the condition holds, and take no room when it does not (a frame with printWhenExpression and removeLineWhenBlank) |
each : {lines} | Its parts repeat for every row of a nested list; field lines inside it declare the rows' fields, when they need a class (a list component over a subdataset) |
import "parts.ferro" | Another file's definitions, styles and fields, from the template's folder or the resource folders |
A part placed this way floats (it moves down when the one above it grows) and a text field grows with its text, so nothing
overlaps when a value is longer than expected. Parts that give x,y stay where they say. convert writes
the result as JRXML with every coordinate worked out, which Jaspersoft Studio and JasperReports open like any other report.
Everything JRXML 7 can say, .ferro can say, so converting between them loses nothing:
ferroreport convert invoice.jrxml -o invoice.ferro # JRXML 6 or 7 -> .ferro ferroreport convert invoice.ferro -o invoice.jrxml # .ferro -> JRXML 7, for Jaspersoft Studio 7 ferroreport convert old.jrxml --to jrxml -o new.jrxml # JRXML 6 -> JRXML 7
From code: convert(template, "ferro") in JavaScript, ferroreport.convert(template, to="ferro") in
Python, ferroreport::template::from_jrxml, to_jrxml and ferroreport::convert::jrxml_to_v7
in Rust. Every fixture renders to the same pixels from its JRXML, its JRXML 7 and its .ferro.
The designer
The designer makes and changes templates in the browser, without writing them and without knowing JasperReports: the page in the middle, the fields of your data on the left, and what the selected part looks like on the right. It runs on your computer (the engine is WebAssembly), so neither the template nor the data leave it, and it keeps your work in the browser until you start a new report. It speaks English and Spanish (the EN / ES switch; at first, your browser's language), and the first time it opens it shows a three-step guide, which Help, Getting started shows again.
- Start from the invoice example, a blank report or a file (File, Open a file…: a
.ferroor.jrxml; a.ferrothat imports others opens when you select them together, and a JSON file selected with it becomes the data). - Add your data: Upload data file, or Edit sample data (a list of rows in JSON). The designer lists its fields with their types in plain words (text, number, whole number, date, yes or no, list).
- Drag a field onto the page, or select an area and click the field. The areas have plain names: Report title (top of the first page), Top of every page, Column titles, Each row of your data (it repeats), Below the rows, Bottom of every page, End of the report (totals); their JasperReports names are in their tooltips. An empty area is a slim strip that says Add something here. A field dropped on the rows gets a column title above it; numbers are aligned right with a format; a list (an array in each row) becomes a part that repeats for each item, with its fields inside.
- Select a part to change it. Its Text box holds words and fields the way
.ferrowrites them,Invoice {number} · {customer}: type {, or press Insert a field, to choose one, and the page shows each field as a pill with its name. A text that is worked out with a formula (a method call, arithmetic, a condition) is shown under Advanced, as JasperReports writes it, and is saved as it was. The rest is in sections: Look (font, size, bold, italic, underline, colors), Alignment, Border, and, folded, Position and size and Advanced (grow to fit, blank when there is no value, show only when, the formula). Number formats are chosen by an example (1,234.56, $1,234.56, 12%, 2026-11-24). Ctrl+Z undoes; the arrow keys move. - Download PDF (the main button), or Excel, Word or PowerPoint from its menu; the Preview tab shows the PDF, made again a moment
after every change. File saves the template as
.ferroor.jrxml(JasperReports 7). When the report cannot be made, a message over the page says why in plain words and what to do, with the engine's own message under Technical details.
Parts it cannot edit yet (charts, tables, crosstabs, subreports, barcodes) are shown as boxes and saved as they were.
Images are kept inside the template as data: URIs, which ferroreport reads and JasperReports does not: give
JasperReports the image as a file instead. A .ferro it saves has every position written out, as
convert writes it, and imports and defs are expanded.
Editors can do the same from JavaScript: toTree(template) gives any template as a tree of its JRXML 7 form,
and fromTree(tree, "ferro" | "jrxml") writes it back (see JavaScript).
Command line
ferroreport render <template.jrxml|template.ferro> [options] ferroreport doctor <template> ferroreport convert <template> [-o <output>] [--to ferro|jrxml] ferroreport migrate <folder|templates...> [--report <file.md|file.json>] [--resources <dir>] [--strict] [--jasper <lib> [--keep <dir>]] [--to ferro|jrxml --out <dir>] ferroreport serve [options]
render
| Option | Meaning |
|---|---|
-d, --data <file.json> | Rows: a JSON array of objects, or one object per line. - reads them from standard input. Omit for reports without data. The file is read as the report needs it, so it can be larger than memory |
-p, --params <file.json> | Parameter values |
-o, --output <file> | Output file (default: the template name with .pdf). The extension picks the format: .pdf, .xlsx, .docx, .pptx, .ods, .odt, .csv or .html. - writes to standard output |
-f, --format <pdf|xlsx|docx|pptx|ods|odt|csv|html> | Output format, when the file name does not say it (for example with -o -) |
--xlsx-numbers | In Excel and ODS, writes numbers as numbers with their format pattern instead of as the formatted text. See Excel and CSV |
--csv-safe | In CSV, puts an apostrophe before values a spreadsheet would run as a formula. Use it when the data comes from other people |
--tagged | In PDF, says what the content is, for screen readers. See Accessible PDFs |
--pdfa <2b|2u|2a|3b|3u|3a> | Writes PDF/A. See PDF/A, attachments, encryption |
--attach <file[:mime/type]> | Carries a file inside the PDF. Repeatable |
--user-password <pw> | Encrypts the PDF (AES-256); this password opens it (an empty one opens it without asking). Also FERROREPORT_PDF_USER_PASSWORD |
--owner-password <pw> | Lifts the permissions. Also FERROREPORT_PDF_OWNER_PASSWORD; without one, nobody can lift them |
--permissions <list> | What readers allow without the owner password: print, copy, modify, annotate, fill, accessibility, assemble, all, separated by commas (default: none). Encrypts the PDF too |
--max-pages <n> | Stops if the report goes over this many pages. See Large reports and limits |
--max-row <MB> | Stops at a row of data larger than this. Default 256 |
--db <url> | Fills the report from its own SQL query, and its subreports from theirs (FERROREPORT_DB; password in FERROREPORT_DB_PASSWORD). See Rows from a database |
--timeout <seconds> | Stops if the render takes longer than this |
-l, --locale <tag> | Number and date formatting: en_US (default), es_DO, es_MX, es_ES |
--font Family=file.ttf[:bold][:italic] | Registers an extra font. Repeat it for each style |
--font-set "Name=Family,Family" | Defines a font set, as a JasperReports font extension does. See Fonts |
--font-fallback | Draws characters a text's font lacks in another font that has them. See Fonts |
-r, --resources <dir> | Extra directory for images and subreports. The template's own directory is always searched |
--now <YYYY-MM-DDTHH:MM:SS> | Fixes the value of new Date(), for reproducible output |
-q, --quiet | Does not print the timing line |
# From a script or another program: rows in, PDF out cat rows.json | ferroreport render invoice.jrxml -d - -p params.json -o - -q > invoice.pdf # The same report as an Excel workbook, or as CSV ferroreport render invoice.jrxml -d rows.json -p params.json -o invoice.xlsx ferroreport render invoice.jrxml -d rows.json -o - -f csv -q > invoice.csv
# With a company font and a shared images folder ferroreport render invoice.jrxml -d rows.json \ --font "Montserrat=fonts/Montserrat-Regular.ttf" --font "Montserrat=fonts/Montserrat-Bold.ttf:bold" \ --resources ./brand
doctor
Lists what a template uses and whether ferroreport can render it. Run it on a template before you rely on it. See Check a template.
convert
Rewrites a template: JRXML (6 or 7) as .ferro, .ferro as JRXML 7, or JRXML 6 as
JRXML 7, the way JasperReports 7 writes its own samples. The output's extension, or --to ferro /
--to jrxml, picks the format; without either, a JRXML becomes .ferro and a .ferro becomes
JRXML. Without -o the result goes to standard output. Style templates (.jrtx) convert too.
migrate
Checks every template of a folder and its subfolders (.jrxml and .ferro) before you move to ferroreport:
whether it loads, what it uses, what is not supported yet, and whether it renders with no rows (pictures are looked for next to
each template, in its parent folder and in every --resources folder). It prints a line per template and a summary;
--report migration.md (or .json) writes every template's result. With --to ferro --out converted/
(or --to jrxml, for JRXML 7) it also writes each template converted, in the same folders. It exits with 1 when a
template cannot be loaded, so it can stop a build; with --strict also when one uses something not supported yet,
stops when rendered with no rows, or differs from JasperReports.
Compared with JasperReports itself
With --jasper lib/, the folder of your JasperReports jars (6 or 7, with their dependencies, as your application
runs them) and a JDK 11 or newer on the PATH, every template that loads is also rendered by JasperReports, in one Java process,
and by ferroreport, from the same rows: <name>.json or data.json next to the template, and
parameters from <name>.params.json or params.json (locale en_US, time zone UTC in both). For each
it reports the pages of each, whether every text and number is the same and in the same place (their CSV exports, compared line
by line), and how long each took to fill and write the PDF. --keep compared/ keeps both PDFs and both CSVs of every
template, to look at side by side. Images, styles and subreports are read from the template's folder; nothing is written there.
Over this project's own test templates, with JasperReports 6.20.6:
$ ferroreport migrate fixtures/ --jasper jasperreports-6.20.6/lib --keep compared/
✓ fixtures/02-invoice/report.jrxml (JRXML 6)
with the rows of fixtures/02-invoice/data.json: 2 pages in both, every text and number the same; JasperReports 228 ms, ferroreport 2.5 ms
...
compared with JasperReports: 46 the same pages and text, 0 differ, 2 JasperReports could not render; filling and writing the PDFs took JasperReports 7676 ms in all (its first template includes starting up), ferroreport 361 ms
$ ferroreport migrate reports/ --report migration.md
✓ reports/invoice.jrxml (JRXML 6)
✓ reports/sales.jrxml (JRXML 6)
- hql query is not run (only SQL is): pass the rows it gives
! reports/legacy/map.jrxml (JRXML 6)
- <component> elements are not supported yet and are skipped
3 templates: 1 supported, 1 supported once you pass the rows their non-SQL query gave, 1 use features not supported yet, 0 cannot be loaded; 0 stop when rendered with no rows (they may need rows, parameters or pictures)
serve
Starts the HTTP API. POST /render/invoice renders invoice.jrxml from the
templates directory, or invoice.ferro when there is no JRXML.
| Option | Environment variable | Meaning |
|---|---|---|
--host <addr> | FERROREPORT_HOST | Address to listen on. Default 127.0.0.1; the Docker image uses 0.0.0.0 |
-P, --port <n> | FERROREPORT_PORT | Port. Default 8080 |
-t, --templates <dir> | FERROREPORT_TEMPLATES | Directory of templates for POST /render/<name> |
-r, --resources <dir> | Extra directory for images and subreports. Repeatable | |
--token <secret> | FERROREPORT_TOKEN | Requires Authorization: Bearer <secret> on every request. The server refuses to listen beyond localhost without it |
--allow-anonymous | FERROREPORT_ALLOW_ANONYMOUS=1 | Listens beyond localhost without a token. Only for ports that your own services alone can reach |
--rate-limit <n> | Most requests per minute from one client address; over it the answer is 429. Default: no limit | |
--max-body <MB> | Largest request accepted. Default 50 | |
--db <url> | FERROREPORT_DB | The database the SQL queries of templates from --templates run on, when a request sends no rows. Templates sent in a request never get it |
--workers <n> | Requests rendered in parallel. Default: the number of CPUs | |
--timeout <seconds> | Longest a render may take. Default 60; 0 for no limit | |
--max-pages <n> | Most pages a report may have. Default: no limit | |
--cache <n> | Parsed templates kept in memory, so a template sent again is not parsed again. Default 128; 0 for none | |
--access-log | Prints a line per request: method, path, status and time | |
--spool-memory <MB> | FERROREPORT_SPOOL_MEMORY | How much of one document is kept in memory until it is complete; the rest goes to a file. Default 32 |
--spool-dir <dir> | FERROREPORT_SPOOL_DIR | Where those files go. Default: the system's temporary directory (/tmp in the Docker image) |
--spool-disk <MB> | FERROREPORT_SPOOL_DISK | Disk all requests together may use for them. Default 4096 |
HTTP API (any language)
For Java, C#, PHP, Go, Ruby and anything else that can make an HTTP request. Run the server next to your application:
docker run -p 8080:8080 \ -v "$PWD/templates:/templates" -e FERROREPORT_TEMPLATES=/templates \ -e FERROREPORT_TOKEN=change-me \ ghcr.io/cristianencarnacion/ferroreport
| Request | Does | Returns |
|---|---|---|
POST /render/<name> | Renders <name>.jrxml from the templates directory (subfolders allowed: /render/sales/invoice) | application/pdf, or the Excel or CSV file with format |
POST /render | Renders the template sent in the request | application/pdf, or the Excel or CSV file with format |
POST /inspect | Reports a template's parameters, fields and unsupported features | JSON |
GET /health | For load balancers. Answers without the token | {"status": "ok", "version": "1.2.0"} |
GET /metrics | Counters for Prometheus: renders, errors, renders stopped by a limit, renders stopped because the client left, documents sent as they rendered, time spent, pages, rows, bytes sent, template cache hits and misses, renders in flight, disk in use for documents | Prometheus text |
The request body is JSON:
| Key | Meaning |
|---|---|
data | Array of rows. For more rows than you want in memory, send them one per line instead |
params | Object of parameter values |
locale | en_US (default), es_DO, es_MX, es_ES |
now | Fixed value of new Date(), ISO-8601 |
format | html returns a web preview; pdf (default), xlsx (returns application/vnd.openxmlformats-officedocument.spreadsheetml.sheet), docx, pptx (application/vnd.openxmlformats-officedocument.presentationml.presentation), ods (application/vnd.oasis.opendocument.spreadsheet), odt (application/vnd.oasis.opendocument.text) or csv (text/csv). Also accepted in the URL: /render/invoice?format=xlsx |
tagged | true for a tagged PDF. See Accessible PDFs |
pdfa | "2b", "2u", "2a", "3b", "3u" or "3a" for PDF/A. See PDF/A, attachments, encryption |
password, ownerPassword, permissions | Encrypt the PDF: the password that opens it, the one that lifts the permissions, and what is allowed without it (a list or a text with commas) |
csvSafe, xlsxNumbers | true to guard CSV against spreadsheet formulas in the data, or to write numbers as numbers in Excel and ODS. See Excel and CSV |
resources | Images and subreport templates as base64, by the path the template uses: {"logo.png": "iVBOR..."} |
template | POST /render and /inspect only: the JRXML source text |
templateName | POST /render only: a template from the templates directory, instead of template |
Errors come back as {"error": "what went wrong"} with one of these statuses: 400 the request is malformed,
401 the token is missing or wrong, 404 the template does not exist, 411 the request has no
Content-Length and asks to switch protocols, 413 the body is too large
or the render went over the page or time limit, 429 the client asked too often (--rate-limit), 422 the template or its data cannot be rendered,
507 the document is too large for the memory and disk the server may use (--spool-memory, --spool-dir, --spool-disk).
A document is sent only once it is complete, with its Content-Length: the answer is the whole document or an error,
never part of one. It comes with two more headers: Server-Timing (milliseconds spent parsing the template, 0 when it
came from the cache, and rendering) and X-Report-Pages.
# curl
curl -X POST localhost:8080/render/invoice \
-H 'Authorization: Bearer change-me' -H 'Content-Type: application/json' \
-d '{"data": [{"sku": "FX-1000", "qty": 21, "price": "185.00"}], "params": {"CUSTOMER": "Caribe"}}' \
-o invoice.pdf
# The same report as Excel
curl -X POST 'localhost:8080/render/invoice?format=xlsx' \
-H 'Authorization: Bearer change-me' -H 'Content-Type: application/json' \
-d '{"data": [...], "params": {...}}' -o invoice.xlsx
// Java: use the Java library, which talks to this server too Ferroreport reports = Ferroreport.server(URI.create("http://localhost:8080"), "change-me"); byte[] pdf = reports.named("invoice").rows(lines).param("CUSTOMER", "Caribe").render();
// C#
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new("Bearer", "change-me");
var response = await http.PostAsJsonAsync("http://localhost:8080/render/invoice", new { data = rows, @params = parameters });
response.EnsureSuccessStatusCode();
byte[] pdf = await response.Content.ReadAsByteArrayAsync();
// PHP
$ch = curl_init("http://localhost:8080/render/invoice");
curl_setopt_array($ch, [
CURLOPT_POSTFIELDS => json_encode(["data" => $rows, "params" => $params]),
CURLOPT_HTTPHEADER => ["Content-Type: application/json", "Authorization: Bearer change-me"],
CURLOPT_RETURNTRANSFER => true,
]);
$pdf = curl_exec($ch);
Large reports over HTTP
Two things can be changed, each on its own, for reports with more rows than you want in memory.
Rows one per line. Send Content-Type: application/x-ndjson with the request (everything in the table above
except data) on the first line, and one row per line after it. The server reads the rows as the report asks for them,
so neither side holds them all: a million rows render with the server at about 50 MB. Send them straight from a query:
# rows.ndjson
{"params": {"YEAR": 2026}}
{"sku": "FX-1000", "qty": 21, "price": "185.00"}
{"sku": "FX-2000", "qty": 4, "price": "92.50"}
curl -X POST localhost:8080/render/sales -H 'Authorization: Bearer change-me' \
-H 'Content-Type: application/x-ndjson' -T rows.ndjson -o sales.pdf
# or without a file, as the database produces them
psql -At -c "select row_to_json(s) from sales s" | { echo '{"params": {"YEAR": 2026}}'; cat; } | \
curl -X POST localhost:8080/render/sales -H 'Authorization: Bearer change-me' \
-H 'Content-Type: application/x-ndjson' -T - -o sales.pdf
The first line may be as large as --max-body; the rows have no limit of their own (--timeout and
--max-pages are what stop a report that is too large).
The document as it renders. By default the server keeps the document until it is complete (in memory up to
--spool-memory, then in a file), so that an error is always an error and never half a PDF. Add
Prefer: respond-streaming and the document is sent while it renders instead: the first bytes arrive in a fraction of
a second, however long the report is, and nothing is kept on the server. The answer says so with
Preference-Applied: respond-streaming.
| Default | Prefer: respond-streaming | |
|---|---|---|
| First byte | When the report is finished | At once |
| An error while rendering | An error status and {"error": ...}; no document | Before the first 64 KB: the same. After that the status is already 200, so the response is cut short in a way every HTTP client reports as an error (curl exits with 56, Java throws IOException, Python raises IncompleteRead). Never keep a file whose download failed |
| The client goes away | The render runs to its end or to --timeout | The render stops within milliseconds |
| Headers | Content-Length, X-Report-Pages, Server-Timing | Transfer-Encoding: chunked |
| Server memory and disk | The document, up to --spool-memory; the rest on disk | None for the document. Rows sent one per line are put aside first (a request cannot be read while it is being answered) |
Both give the same bytes. Use the default unless you need the first bytes early (a browser download of a long report, a
gateway with a short time-out) or want abandoned downloads to stop costing work. In Docker the files go to /tmp,
which the image provides; with a read-only root filesystem, mount a volume there or set FERROREPORT_SPOOL_DIR.
Without a place to write, documents over --spool-memory are answered with 507.
These promises are checked on every change by tools/http_check.py:
a million rows, 50 clients at once, a client that leaves half way, a wrong row in each mode, and the same bytes as the command
line for every test report.
JavaScript
For Node.js 18+, Deno, Bun and browsers. The engine is WebAssembly: no native build step, no JVM.
import { render, inspect, convert, version } from "ferroreport";
import { readFileSync, writeFileSync } from "node:fs";
const pdf = render(
readFileSync("invoice.jrxml", "utf8"), // template: the JRXML text
rows, // data: array of objects, or JSON text
{ CUSTOMER: "Distribuidora Caribe" }, // params: object, or JSON text
{
locale: "es_DO",
now: new Date("2026-03-05T10:00:00"), // optional: value of new Date() in expressions
resources: { // optional: images and subreports, by the path the template uses
"logo.png": readFileSync("logo.png"),
"lines.jrxml": readFileSync("lines.jrxml", "utf8"),
},
},
);
writeFileSync("invoice.pdf", pdf); // pdf is a Uint8Array
// Excel or CSV: the same call with options.format
writeFileSync("invoice.xlsx", render(template, rows, params, { format: "xlsx" }));
| Function | Returns |
|---|---|
render(template, data?, params?, options?) | Uint8Array with the PDF (or the Excel workbook or CSV text with options.format). Throws an Error with the reason if the template cannot be rendered |
inspect(template) | { name, parameters, fields, warnings }. warnings lists what the engine does not support in that template |
convert(template, to) | The template rewritten: to is "ferro" or "jrxml" (JRXML 7). See Templates in .ferro |
toTree(template, options?) | Any template (JRXML 6 or 7, or .ferro) as a tree an editor can change: its JRXML 7 form, one { tag, attrs, children, text? } per element, with attrs as [name, value] pairs. options.resources holds the files a .ferro imports. The designer is built on it |
fromTree(tree, to?) | The tree written back as a template: to is "jrxml" (default) or "ferro" |
version() | The engine version |
options holds locale, now, resources (as above) and format:
"pdf" (default), "xlsx", "docx", "pptx", "ods", "odt", "html" or "csv" (UTF-8 bytes). Also maxPages (stop a
report that grows past that many pages), csvSafe (guard CSV against spreadsheet formulas in the data) and
xlsxNumbers (numbers as numbers in Excel and ODS). For PDF: tagged, pdfa ("3b"...),
attachments ([{ name, data, mime }]), and password, ownerPassword and
permissions to encrypt it (see PDF/A, attachments, encryption).
In a browser, or with a bundler that picks the web build, load the engine once before the first render:
import init, { render } from "ferroreport";
await init();
const pdf = render(template, rows, params);
window.open(URL.createObjectURL(new Blob([pdf], { type: "application/pdf" })));
// Express: send a PDF
app.get("/invoices/:id.pdf", async (req, res) => {
const { rows, params } = await loadInvoice(req.params.id);
res.type("application/pdf").send(Buffer.from(render(template, rows, params, { locale: "es_DO" })));
});
Templates read files only from options.resources, so the JavaScript build never touches the disk on its own.
Python
import ferroreport
pdf = ferroreport.render(
"invoice.jrxml", # a path, or the JRXML text itself
data=rows, # list of dicts or objects, or JSON text
params={"CUSTOMER": "Distribuidora Caribe"},
locale="es_DO",
resource_dirs=["./brand"], # optional: extra folders for images and subreports
resources={"logo.png": logo_bytes}, # optional: images and subreports held in memory
now=datetime(2026, 3, 5, 10, 0), # optional: value of new Date() in expressions
format="pdf", # optional: "pdf", "xlsx" (Excel), "docx", "pptx", "ods", "odt", "csv" or "html"
) # returns bytes
ferroreport.render_to_file("invoice.jrxml", "invoice.xlsx", rows) # format from the extension
# Rows that do not fit in memory: read from a file as needed, pages written as they finish
stats = ferroreport.render_to_file("sales.jrxml", "sales.pdf", data_file="sales.jsonl",
max_pages=50_000, timeout=120)
print(stats) # {"pages": 23810, "rows": 1000000}
| Function | Does |
|---|---|
render(template, data=None, params=None, *, locale, resources, resource_dirs, now, format, max_pages, timeout, csv_safe, xlsx_numbers, tagged, pdfa, attachments, password, owner_password, permissions) | Returns the file as bytes: PDF by default, Excel with format="xlsx", Word with format="docx", PowerPoint with format="pptx", OpenDocument with format="ods" or format="odt", CSV with format="csv", HTML with format="html". max_pages and timeout (seconds) stop a report that grows past what you expect; pdfa, attachments and the passwords and permissions are described in PDF/A, attachments, encryption |
render_to_file(template, output, data=None, params=None, *, data_file, ...) | Same arguments; writes the file to output as it is made and returns {"pages", "rows"}. Without format, the extension (.pdf, .xlsx, .docx, .pptx, .ods, .odt, .csv, .html) decides. data_file is a file of rows (a JSON array or one object per line) read as the report needs it, instead of data |
inspect(template) | Returns a dict with name, parameters, fields and warnings |
convert(template, to="ferro") | Returns the template rewritten, as .ferro or (to="jrxml") JRXML 7. See Templates in .ferro |
FerroreportError | Raised when a template cannot be parsed, filled or exported |
Python values are converted for you: datetime and date become dates, Decimal keeps its exact
digits, bytes become images, and plain objects are read through their attributes. When the template is a path, its
folder is searched for images and subreports. Rendering releases the GIL, so threads render in parallel.
# Django
def invoice_pdf(request, pk):
invoice = Invoice.objects.get(pk=pk)
pdf = ferroreport.render("reports/invoice.jrxml", list(invoice.lines.values()),
{"CUSTOMER": invoice.customer.name}, locale="es_DO")
return HttpResponse(pdf, content_type="application/pdf")
# FastAPI
@app.get("/invoices/{pk}.pdf")
def invoice_pdf(pk: int):
rows, params = load_invoice(pk)
return Response(ferroreport.render("reports/invoice.jrxml", rows, params), media_type="application/pdf")
Java
A library with no dependencies, for Java 11 and newer (Quarkus, Spring, plain Java). It runs the native engine and feeds it the rows as they are read, so a report can be far larger than the heap.
<!-- pom.xml --> <repositories> <repository><id>jitpack.io</id><url>https://jitpack.io</url></repository> </repositories> <dependency> <groupId>com.github.cristianEncarnacion</groupId> <artifactId>ferroreport</artifactId> <version>v1.2.0</version> </dependency>
Ferroreport reports = Ferroreport.local();
byte[] pdf = reports.template(Path.of("reports/invoice.jrxml"))
.rows(lines) // List<Map<String, Object>>, or any Iterable
.param("CUSTOMER", "Distribuidora Caribe")
.locale("es_DO")
.render();
// A query straight to a file, in constant memory
try (ResultSet sales = statement.executeQuery("select * from sales order by region")) {
reports.template(Path.of("reports/sales.jrxml"))
.rows(sales)
.maxPages(50_000).timeout(Duration.ofMinutes(2))
.renderTo(Path.of("sales.pdf")); // .xlsx, .docx, .pptx, .ods, .odt, .csv and .html work the same way
}
// Quarkus / JAX-RS: stream the PDF into the response
StreamingOutput body = out -> reports.template(Path.of("reports/invoice.jrxml")).rows(lines).renderTo(out);
| Call | Does |
|---|---|
Ferroreport.local(), local(Path) | The engine on this machine. It is found through -Dferroreport.bin or FERROREPORT_BIN, then the PATH, and otherwise downloaded once from the project's releases and checked against their SHA-256 list (-Dferroreport.download=false forbids that) |
Ferroreport.server(URI, token) | A ferroreport serve instance (0.9.0 or later), for a sidecar or a shared service. Rows are sent to it one per line as they are read, so a large ResultSet is never in memory on either side, and the answer is the whole document or an exception |
.template(Path), .source(String), .named(String) | A report from a file, from JRXML text, or by the name a server knows it by |
.rows(Iterable), .rows(ResultSet) | The rows, read one at a time: Maps of field name to value (nested Maps and Lists feed subreports and tables), or the columns of a query |
.param, .params, .locale, .now, .format, .resources | Parameters, formatting locale, the value of new Date(), output format, extra folders for images and subreports |
.maxPages(n), .timeout(Duration), .csvSafe(true), .xlsxNumbers(true), .tagged(true), .pdfa("3b"), .attach(Path), .password(user, owner), .permissions("print", ...) | Limits and export options, as on the command line (the local engine gets the passwords through its environment, never its command line; attachments need the local engine) |
.render(), .renderTo(Path), .renderTo(OutputStream) | The document as bytes, as a file written page by page (nothing is left if it fails), or into a stream as it is made |
FerroreportException | Thrown with the engine's message when a report cannot be rendered |
In a container, copy the engine into the image so nothing is downloaded at run time:
COPY --from=ghcr.io/cristianencarnacion/ferroreport /ferroreport /usr/local/bin/ferroreport.
Rust
use ferroreport::Renderer;
let template = std::fs::read_to_string("invoice.jrxml")?;
let rows: serde_json::Value = serde_json::from_str(&std::fs::read_to_string("rows.json")?)?;
let params = serde_json::json!({ "CUSTOMER": "Distribuidora Caribe" });
let pdf: Vec<u8> = Renderer::new()
.locale("es_DO")
.resource_dir("reports") // images and subreports are read from here
.render_json(&template, &rows, ¶ms)?;
std::fs::write("invoice.pdf", pdf)?;
| Method | Does |
|---|---|
Renderer::new() | A renderer with the bundled fonts and the en_US locale |
.locale(tag) | Number and date formatting |
.now(datetime) | Fixes the value of new Date() |
.resource_dir(dir) | Adds a folder for images and subreports. Templates cannot read outside these folders |
.resource(name, bytes), add_resource(name, bytes) | Adds an image or subreport held in memory |
register_font(family, bold, italic, data) | Registers a TrueType or OpenType font |
register_font_set(name, &[families]) | Defines a font set (see Fonts) |
.font_fallback(true), set_font_fallback(true) | Draws characters a text's font lacks in another font that has them |
render_json(template, rows, params) | Parses, fills and exports to PDF in one call |
render_json_as(template, rows, params, Format::Xlsx) | The same, to Format::Pdf, Format::Xlsx, Format::Docx, Format::Pptx, Format::Ods, Format::Odt, Format::Csv or Format::Html |
ferroreport::parse, fill, to_pdf on the renderer | The three steps separately, to parse a template once and fill it many times |
render_report_json(&report, rows, params, format) | Renders a template already parsed with ferroreport::parse |
render_to(&report, rows, params, format, writer) | Renders rows that arrive one at a time (any iterator of records; JsonRows reads them from JSON text) to any std::io::Write, page by page. Returns the number of pages and rows. See Large reports and limits |
fill_to(&report, rows, params, &mut sink) | Hands each finished page to a PageSink of your own |
.limits(Limits { max_pages, timeout }) | Stops a render that goes over, with Error::Limit |
.csv_options(...), .xlsx_options(...) | Options the render methods use for CSV, and for Excel and ODS |
to_xlsx(doc, &XlsxOptions), to_ods(doc, &XlsxOptions), to_csv(doc, &CsvOptions), export(doc, format) | Export a filled document to Excel, ODS or CSV (export to any format). XlsxOptions { detect_cell_type } writes numbers as numbers; CsvOptions sets the field and record delimiters |
font_substitutions() | Font families the last renders had to replace |
Images, subreports and style templates
A template refers to other files by relative path: "logo.png" in an image expression, "lines.jasper" in a
subreport expression. ferroreport looks for them in the template's folder, then in the resource folders you add, then among the
resources you pass in memory. A path can never leave those folders, and remote URLs are not fetched.
Images are PNG, JPEG or GIF (its first picture, with its transparent color). They can also come from the data: a byte[] field with base64 content, or a string field with a
base64 expression.
A subreport gets its rows from a nested array in the parent row:
# Parent row
{ "order": "ORD-2026000", "customer": "Grupo Ramos",
"lines": [ { "product": "Clavos 3\"", "qty": 26, "price": 65.0 }, ... ] }
# In the parent template: a field of class java.util.List, and
<dataSourceExpression><![CDATA[new JRMapCollectionDataSource($F{lines})]]></dataSourceExpression>
<subreportExpression><![CDATA["lines.jasper"]]></subreportExpression> # read from lines.jrxml
JRBeanCollectionDataSource, ((JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("lines") and
JREmptyDataSource work the same way. Subreport parameters and return values are supported.
Style templates are found the same way: <template><![CDATA["styles.jrtx"]]></template> reads
styles.jrtx from the template's folder, a resource folder or the resources in memory (over HTTP, the
resources of the request). A .jrtx that includes another is read with it, the included one looked for
next to it first. Styles are taken in JasperReports' order: those of each template after the templates it includes, then the
report's own; a style defined again replaces the earlier one for what comes after it. The location can be a string or a
parameter whose default is one. In Rust, parse with Renderer::parse instead of ferroreport::parse,
which does not read files.
Tables
Tables (jr:table) work as they do in JasperReports: the table iterates over a <subDataset>
whose rows come from the dataSourceExpression of its datasetRun, usually a nested array of the
current row, and its datasetParameters pass values in. Fields of the main report are not visible inside the
table; pass them as parameters.
<subDataset name="lines">
<parameter name="ORDER" class="java.lang.String"/>
<field name="product" class="java.lang.String"/> ...
</subDataset>
...
<jr:table>
<datasetRun subDataset="lines">
<datasetParameter name="ORDER"><datasetParameterExpression><![CDATA[$F{order}]]></datasetParameterExpression></datasetParameter>
<dataSourceExpression><![CDATA[new JRMapCollectionDataSource($F{lines})]]></dataSourceExpression>
</datasetRun>
<jr:column width="235"> ... </jr:column>
</jr:table>
Supported: columns and nested column groups, table header and footer, column headers (printed again on every page
the table continues on), column footers, detail cells, group header and footer cells for the subdataset's groups,
printWhenExpression on columns, the no-data cell (whenNoDataType="NoDataCell") and
subdataset variables. The rows come from the data source expression, or, when the dataset run passes $P{REPORT_CONNECTION}, from the subdataset's SQL query on the report's database.
Lists (jr:list) use the same datasetRun: the list contents are repeated for each row, one
below the other, and continue on the next page when they do not fit.
Crosstabs
Crosstabs made in Jaspersoft Studio render as they do in JasperReports. The rows come from the report itself (place the crosstab
in the summary band) or from a subdataset through its datasetRun, for example one crosstab per detail row over a nested
JSON array.
- Row and column groups sort their bucket values ascending or descending, and print their totals at the start, the end or not at all.
Group headers sit at the start, middle or end of the cells they span (
headerPosition). - Measures can be Sum, Count, DistinctCount, Average, Highest, Lowest, First or Nothing. In a cell,
$V{measure}is the value of that cell,$V{measure_group_ALL}the total of a group,$V{measure_rowGroup_columnGroup_ALL}the total of both, and$V{group}the bucket value. Cells without data show zero for sums and counts. Totals add up the totals of the buckets below them, as Jasper does, so decimals round the same way. - A crosstab wider than its element is cut into column parts, printed one below the other (
columnBreakOffsetapart) with the row headers repeated. One taller than the page continues on the next page with the column headers repeated (repeatColumnHeaders,repeatRowHeaders). <crosstabParameter>values are evaluated in the report and read with$P{}inside the crosstab.percentageOf="GrandTotal"shows a measure as a percentage of the grand total (100 × value / total, in the measure's class: whole numbers divide as integers, BigDecimal rounds half up).orderByExpressionsorts a group's buckets by a value computed on each bucket's totals, for example$V{amountMeasure}to list regions by their sales; ties keep the natural order.
Not yet: bucket comparators (comparatorExpression), and crosstabs over the rows of a group only (they use all the rows
read so far). ferroreport doctor warns about these.
Excel and CSV
A template that renders to PDF also exports to an Excel workbook (.xlsx) or a CSV file. Both follow JasperReports' own
exporters with their default settings, so the spreadsheet comes out the way it did with Jasper: every fixture in the test suite gives
the same worksheet, styles and CSV text as JasperReports 6.20, byte for byte.
Excel
- All pages go on one sheet named after the report, one below the other, page margins included.
- The edges of the elements cut each page into columns and rows. A column is as wide as the gap between two cuts (in Excel units of 6 points) and a row as tall as its gap, in points.
- Each text sits in the cells it covers, merged, with its font, size, bold, italic, underline, color, background, borders and alignment. Rotated text is rotated in the cell. Styled and HTML text keeps its formatting run by run.
- A text that does not fit its box is cut the same way as in the PDF.
- Lines become the border of the cells they lie on, rectangles fill and outline their cells, and frames give their background and borders to the cells inside them.
- Images sit over their cells with the same scale mode (RetainShape, FillFrame, Clip) and alignment. Charts and barcodes are drawn as pictures at twice Jasper's resolution, so they stay sharp.
- Where two elements overlap, the one on top wins, as in Jasper; the other is left out.
- Values are written as the text you see in the PDF (
3,885.00), like Jasper. With--xlsx-numberson the command line, orXlsxOptions { detect_cell_type: true }in Rust, numbers are written as numbers with their format pattern, so the spreadsheet can add them up.
CSV
Only texts are exported. Every line of a page where a text starts becomes a row, and every column where a text starts on that page becomes a field. Fields holding a comma, a quote or a line break are quoted; quotes are doubled. Pages follow one another.
A value that starts with =, +, - or @ can be run as a formula by the spreadsheet
that opens the CSV. When the data comes from other people, turn on the guard (--csv-safe, csv_safe=True,
csvSafe: true): those values get an apostrophe in front, which spreadsheets show as text. Numbers such as
-12.50 are left alone. It is off by default so the CSV stays exactly what JasperReports writes.
Not available yet: the old XLS format and the net.sf.jasperreports.export.* properties other than number
detection.
Word
Ask for docx (-o report.docx, format="docx", Format::Docx,
Format.DOCX) and you get a Word document laid out like JasperReports' DOCX exporter: each page is a table cut at the
edges of its elements, and each element sits in the cells it covers. Texts keep their fonts, sizes, colors, styled runs,
alignment, padding, borders and backgrounds; images, charts and barcodes are pictures; lines and rectangles become cell borders
and backgrounds. A page break separates the pages, so the document has as many pages as the PDF. Like Jasper's, the document is
made for reading and light editing, not for reflowing: rounded rectangles and ellipses come out as plain boxes.
PowerPoint
Ask for pptx (-o report.pptx, format="pptx", Format::Pptx,
Format.PPTX) and you get a presentation laid out like JasperReports' PPTX exporter: each page is a slide of the
report's page size, and each element is a shape where it is on the page. Texts are text boxes with their fonts, sizes, bold,
italic, underline, strike-through, colors, styled runs, alignment, padding, background, line spacing and rotation; rectangles
(rounded too), ellipses and lines are shapes with their fill and pen; frames are rectangles under their elements; images are
pictures cut to their element as in the PDF, and charts and barcodes are drawn as pictures. A box with the same border on
every side gets it as the shape's outline, and borders that differ by side are drawn as lines (Jasper's exporter leaves those
out). Links to web pages and other files work, and links to a page or an anchor of the report jump to its slide. Slides are
written as the pages are filled.
Not available yet: the net.sf.jasperreports.export.pptx.* properties (such as a page used as the slide master)
and fonts embedded in the file. PowerPoint and LibreOffice wrap text with their own font metrics, so a line that just fits in
the PDF can wrap in the slide.
OpenDocument (ODS and ODT)
Ask for ods or odt (-o report.ods, format="odt", Format::Ods,
Format.ODT) and you get the files LibreOffice and other OpenDocument applications open, laid out the way
JasperReports' ODS and ODT exporters lay a report out. The spreadsheet is the Excel grid: every page on one
sheet, the same columns, rows, merged cells, fonts, colors, borders, alignment and rotation, images over their cells, charts and
barcodes as pictures. Values are text by default, like Jasper; with --xlsx-numbers numbers are numbers, with a
number style made from their pattern (decimals, grouping, percent, scientific, text around them). The text document is the
Word layout: a table per page, each element in the cells it covers, a page break between pages; ellipses and
slanted lines are drawn as pictures. Links, anchors and page anchors carry over, and the page has the report's size.
Not available yet: the net.sf.jasperreports.export.ods.* and .odt.* properties, dates as date cells,
the per-mille sign in number styles, and upside-down text in ODT.
Large reports are written as they are made, in about the memory of a small one. A document's styles come before its body in the file, so a large report is filled once more first to find them (a spreadsheet three times in all: its columns, its styles, its rows; a text twice), and its rows are then compressed and written as they come: 100,000 rows in 68 MiB as ODS and 37 MiB as ODT, a million rows in 37 MiB as ODT. That needs rows that can be read again, as for large workbooks; rows that can only be read once still give the document, kept in memory until it is written.
Accessible PDFs
A PDF is a picture of pages unless it also says what is on them. With tagging on, the document carries that description (a tagged PDF): each text element is a paragraph and each image, chart and barcode a figure, in reading order; tables and crosstabs are tables, with their rows, their data cells and their header cells, each header saying whether it names a column or a row and each cell how many columns and rows it spans; the lists of an HTML text are lists, each item with its bullet or number and its body; lines, borders and backgrounds are marked as decoration, so a screen reader skips them; and the document has its title and the language of the locale. The pages look exactly the same.
| From | How |
|---|---|
| Command line | --tagged |
| HTTP | "tagged": true in the request |
| Python | tagged=True |
| Java | .tagged(true) |
| JavaScript | { tagged: true } |
| Rust | Renderer::new().tagged(true) |
| The template | <property name="net.sf.jasperreports.export.pdf.tagged" value="true"/> (and
...pdf.tag.language for its language); .ferro templates are tagged unless they say tagged=false |
Two things are yours to say in the template, the way JasperReports has them:
| What | How |
|---|---|
| What an image shows | Its <hyperlinkTooltipExpression> becomes the figure's alternative text. Images without one are announced as "Image", charts as "Chart", barcodes as "Barcode" |
| Headings | <property name="net.sf.jasperreports.export.accessibility.tag" value="h1"/> inside the text's <reportElement>, with h1 to h6 |
| A table drawn by hand with frames | The same property on the frames: table on the outer one, th (or columnheader, rowheader) and td on its cells. Cells at the same height are a row. jr:table and crosstabs need nothing |
Tagged PDFs say they follow PDF/UA-1, the accessibility standard, and every test report is checked against it on each change with veraPDF, the validator the PDF Association maintains: all of them pass. Each tagged test report also has the same pixels as the untagged one. A tagged PDF is larger (an entry per text) and a value known only later, such as "page 3 of 240", makes its page wait instead of being added afterwards.
PDF/A, attachments, signatures, encryption, links
PDF/A
For documents that must be kept for years (invoices, statements, records). --pdfa 2b (or 2u,
2a, 3b, 3u, 3a; pdfa in the packages and the HTTP API) writes PDF/A:
every font inside the document, an sRGB output intent, the conformance declared in the metadata. Level a is also
tagged. A text in one of the PDF standard fonts (a font no one provides) is an error, as in JasperReports:
register the font with --font. The template's net.sf.jasperreports.export.pdfa.conformance property
(pdfa2b...) asks for the same. Every fixture is checked with veraPDF as PDF/A-2a and PDF/A-3b on every push.
Attachments
--attach invoice.xml (or invoice.xml:application/xml) carries a file inside the PDF, the way electronic
invoices carry their XML. PDF/A-3 allows any file; PDF/A-2 refuses them. In the packages: attachments, a list of
paths or of (name, bytes, MIME type).
Signatures
--sign-key signs the PDF with PAdES baseline B-B: a CAdES detached signature (/ETSI.CAdES.detached) over
the whole file, with the signer's certificate bound to it by the signing-certificate-v2 attribute, as Adobe Reader, EU
validators and pdfsig expect.
FERROREPORT_SIGN_PASSWORD=... ferroreport render invoice.jrxml -d rows.json -o invoice.pdf --sign-key company.p12 --sign-reason "Approved" ferroreport render invoice.jrxml -d rows.json -o invoice.pdf --sign-key key.pem --sign-cert cert.pem --sign-location "Santo Domingo"
| Option | Meaning |
|---|---|
--sign-key | A .p12/.pfx (the AES files OpenSSL 3 writes, and the older Triple DES and RC2 ones), its password in FERROREPORT_SIGN_PASSWORD; or a PEM private key, RSA (2048 bits or more) or ECDSA P-256. FERROREPORT_SIGN_KEY does the same |
--sign-cert | With a PEM key: the signer's certificate and its chain (repeatable). The one that matches the key goes first |
--sign-reason, --sign-location, --sign-name, --sign-contact | The signature's details, shown by readers |
A signature goes with PDF/A (every fixture is signed as PDF/A-2b, checked by veraPDF and verified by pdfsig and pyHanko on every
push), not with encryption. serve --sign-key signs every PDF the server sends. In Rust, implement
ferroreport::sign::Signer (a hardware token, a signing service) and pass it to Renderer::sign: the private key
never has to reach ferroreport. A signed document is written in memory before it is sent, since the signature covers all of it.
Encryption
The PDF is encrypted with AES-256, the security handler of PDF 2.0, which every current reader opens.
| Command line | Packages and HTTP API | Template property (net.sf.jasperreports.export.pdf....) | Meaning |
|---|---|---|---|
--user-password | password | encrypted + user.password | Asked for to open the document; empty opens it without asking (the permissions still apply) |
--owner-password | owner_password / ownerPassword | owner.password | Lifts the permissions. Without one, a random password nobody knows is used |
--permissions | permissions | permissions.allowed, permissions.denied | What readers allow without the owner password: print, copy, modify, annotate, fill, accessibility, assemble, all (JasperReports' names, such as PRINTING|COPY, work too) |
A tagged PDF always lets screen readers in, as PDF/UA asks. PDF/A forbids encryption, so asking for both is an error. Keep
passwords out of command lines with FERROREPORT_PDF_USER_PASSWORD and FERROREPORT_PDF_OWNER_PASSWORD (the
Java package does, with its local engine). Objects are encrypted as they are written, so a large report stays in constant memory.
Links and bookmarks
Text fields, images and frames take JasperReports' hyperlinks: hyperlinkType Reference (a URL),
LocalAnchor, LocalPage, RemoteAnchor and RemotePage, with
hyperlinkReferenceExpression, hyperlinkAnchorExpression, hyperlinkPageExpression and
hyperlinkTooltipExpression. anchorNameExpression names a place, and bookmarkLevel puts it in
the PDF's outline (the bookmarks panel). They work in PDF (link annotations and named destinations), Excel (cell hyperlinks and
defined names), Word (hyperlink fields and bookmarks) and HTML, as JasperReports writes them. javascript: and
data: links are not followed in HTML previews.
HTML previews
Ask for html (-o report.html, format="html", Format::Html,
Format.HTML) and you get one web page with every page of the report drawn as it is in the PDF: same positions,
fonts, colors, images, charts and barcodes. The text is real text, so it can be selected, searched and read aloud, and
everything from the template or the data is escaped. The page has no scripts and loads nothing from the network.
Each line of text carries its measured width, so the layout holds even where the browser does not have the report's font
and falls back to another. Use it to show a report in a browser without a PDF viewer; the PDF remains the document to print
or keep. In Rust, HtmlOptions { fragment: true, .. } gives only the pages, to place inside a page of your own.
Large reports and limits
A report does not have to fit in memory. Rows are read as the report asks for them and each page is written as soon as it is finished, so a million rows and 23,810 pages render in about 16 MB, at about 80,000 rows a second on one core.
| From | How |
|---|---|
| Command line | Nothing to do: ferroreport render sales.jrxml -d sales.json -o sales.pdf already reads and writes as it goes. The rows can be a JSON array or one object per line, from a file or from standard input |
| Python | render_to_file("sales.jrxml", "sales.pdf", data_file="sales.jsonl") |
| Rust | renderer.render_to(&report, Box::new(rows), params, Format::Pdf, writer), where rows is any iterator of records (a database cursor, a queue, JsonRows over a file) |
| HTTP | Send the rows one per line (application/x-ndjson): they are read as the report needs them |
| Java | .rows(resultSet) or any Iterable: rows go to the engine (a local process or a server) as they are read |
| JavaScript | Rows arrive in the call, so they are in memory; the document is still built page by page |
What this covers, and what it does not:
- PDF and CSV are written page by page. So are Excel workbooks, in two passes: the columns of a sheet come from
every page, so a large report is filled once to find them and once more to write its rows, which are compressed and sent on
as they are made (100,000 rows: about 3 s and 66 MiB; 500,000: 15 s and 116 MiB). That needs rows that can be read twice: a
file, or rows the command line, the server, Python and Java put aside for you; in Rust,
render_rows_to. Small workbooks are still filled once. A report with more rows than a sheet holds (1,048,576) stops with an error that says so. OpenDocument files are written as they are made too, filled once more first to find their styles (100,000 rows: 68 MiB as ODS, 37 MiB as ODT; a million rows as ODT: 37 MiB). - Values known only later, such as "page 3 of 240", a grand total in the title or a group total in the group header, are added to their page when they are known, without holding the page back. If something is drawn over such a value, its page waits for it instead, so the result is always the same document.
- A crosstab over the report's own rows needs them all, so those rows are kept until the crosstab prints. Crosstabs, tables, lists and subreports over nested data are not affected.
Two limits stop a report that grows past what you expect. Set them whenever templates or data come from other people:
| Limit | Command line and server | Python | Rust | JavaScript |
|---|---|---|---|---|
| Pages | --max-pages | max_pages= | Limits::max_pages | maxPages |
| Time | --timeout (60 s by default in serve) | timeout= | Limits::timeout | not available: there is no clock to check in WebAssembly |
A render that goes over stops with an error (413 from the server) and leaves no file behind.
Rows from a database
A template's own SQL query runs the way JasperReports runs it over JDBC: $P{} values are bound parameters,
$P!{} is pasted into the SQL text, and $X{IN, column, PARAM} (with NOTIN, EQUAL,
NOTEQUAL, LESS, LESS], GREATER, [GREATER and the BETWEEN forms)
becomes its clause. Subreports, tables, lists, crosstabs and charts that pass $P{REPORT_CONNECTION} run their
own query on the same database. Rows are read as the report needs them.
ferroreport render sales.jrxml --db postgres://reports@db:5432/erp -p params.json -o sales.pdf ferroreport render sales.jrxml --db mysql://reports@db:3306/erp -o sales.xlsx ferroreport render sales.jrxml --db "jdbc:sqlserver://db:1433;databaseName=erp;user=reports" -o sales.pdf ferroreport render sales.jrxml --db sqlite:app.db -o sales.pdf
| Database | URL |
|---|---|
| PostgreSQL | postgres://user@host:5432/db (or postgresql://, jdbc:postgresql://); sslmode as in psql: disable, prefer (default) and require encrypt without checking the certificate, verify-ca / verify-full check it, against sslrootcert when given |
| MySQL, MariaDB | mysql://user@host:3306/db (or mariadb://, jdbc:mysql://) |
| SQL Server | sqlserver://host:1433;databaseName=db;user=u (JDBC form; or mssql://) |
| SQLite | sqlite:file.db, or a path ending in .db / .sqlite; opened read-only |
The password goes in FERROREPORT_DB_PASSWORD rather than in the URL, where the process list would show it;
FERROREPORT_DB can hold the URL. Use a database user that can only read: the query runs as the template wrote it.
serve --db gives the database to templates from --templates only; a template sent in a request never
gets it, and a request cannot set a parameter that is pasted into a query ($P!{}). In Rust, implement
ferroreport::sql::Connection for your own pool and use Renderer::connection and
Renderer::render_query_to.
Queries in other languages (HQL, XPath, MDX, MongoDB...) and other databases (Oracle) are not run: hand the engine the rows your application already reads, as they come, and nothing is held in memory.
# PostgreSQL: one JSON object per row, straight into the report
psql -At -c "select row_to_json(s) from (select * from sales order by region) s" mydb \
| ferroreport render sales.jrxml -d - -o sales.pdf
# SQLite, MySQL
sqlite3 -json app.db "select * from sales order by region" | ferroreport render sales.jrxml -d - -o sales.pdf
mysql -N -B -e "select json_object('region', region, 'amount', amount) from sales" mydb \
| ferroreport render sales.jrxml -d - -o sales.pdf
// Java: the ResultSet is read as the report needs it
reports.template(Path.of("sales.jrxml")).rows(statement.executeQuery("select * from sales")).renderTo(Path.of("sales.pdf"));
# Python: any cursor or generator is read one row at a time
cursor.execute("select region, amount from sales order by region")
rows = (dict(zip(("region", "amount"), r)) for r in cursor)
ferroreport.render_to_file("sales.jrxml", "sales.pdf", rows)
Fonts
DejaVu Sans, DejaVu Serif and DejaVu Sans Mono are built in. They are the families of the jasperreports-fonts
extension, so templates that use them match JasperReports exactly. A family the engine does not have is replaced by a built-in one.
Add your own TrueType or OpenType fonts with --font on the command line or register_font in Rust. The
JavaScript and Python packages use the built-in families for now.
A character the text's font does not have is left out of the PDF, as JasperReports leaves it out (when the text is measured for its height it still counts as wide as the font's missing-glyph box, as in JasperReports). To draw it in another font, use a font set or font fallback:
- Font sets work as the
<fontSet>of a JasperReports font extension. With--font-set "Serif Fallback=DejaVu Serif,DejaVu Sans"(orregister_font_set), a text whose font name isSerif Fallbackis drawn in DejaVu Serif, and the characters DejaVu Serif lacks in DejaVu Sans. Like JasperReports, the text is cut into the longest runs one family has, each drawn in the first family (in the order given) that has all of it; so the words around a missing character go to the other family with it. A character no family has stays in the first family, the primary one. Bold and italic text look at the faces of their style first. The families must be registered fonts or the built-in ones. - Font fallback (
--font-fallback, orfont_fallback(true)) does the same for every font, as if each were a font set of itself followed by the--fontfamilies, in the order given, and then DejaVu Sans, DejaVu Serif and DejaVu Sans Mono. It is off by default, because JasperReports does not do it, and texts whose characters are all in their font are drawn as without it.
Either way the text is measured, broken into lines and embedded in the PDF with the font that draws each run. A plain text drawn in more than one font is laid out like styled text, as in JasperReports, and stays plain text in Excel, Word and CSV.
Hyphenation
JasperReports does not hyphenate: a word that does not fit at the end of a line goes to the next one, and a word longer than
the line is cut between letters. ferroreport does the same unless the template asks for hyphenation with its own property,
ferroreport.text.hyphenate, which JasperReports ignores:
<!-- every text of the report, in the language of the render's locale (--locale) --> <property name="ferroreport.text.hyphenate" value="true"/> <!-- or in a language of its own; "false" turns it off --> <property name="ferroreport.text.hyphenate" value="es"/>
In .ferro: property ferroreport.text.hyphenate value=true under report. The setting is the
report's: tables, lists and subreports follow it unless they have their own, and on an element it is not read (the template
loads with a warning; a text in another language can go in a subreport). It is also a parameter of the same name, so a render
can turn it on without changing the template: {"ferroreport.text.hyphenate": "es"} in the parameters. A word that does not fit is cut after the last of its syllables that fits with a hyphen, and the hyphen is
drawn; the rest of the word starts the next line. Only words made of letters are hyphenated, never inside numbers or codes,
with at least two letters before the hyphen and two or three after it, as each language's patterns say. The height of a
stretching text and where a text is cut across pages follow the hyphenated lines. Styled and HTML text, right-to-left and
complex-script text are not hyphenated.
The patterns of English, Spanish, French, Italian, Portuguese and Catalan are built in (about 60 KB). Rust users who need
more build with the hyphenation-all feature (the 48 languages of hypher, about 1.1 MB more), or without
default features to leave hyphenation out. A language without patterns is not hyphenated.
Locale and dates
The locale decides how patterns such as #,##0.00 and dd MMMM yyyy are written: decimal and grouping
separators, month and day names. Supported: en_US, es_DO, es_MX, es_ES.
Dates are kept as written, without time zone conversion. new Date() in an expression is the current time, unless you
fix it with now, which makes the output byte-for-byte reproducible.
Expressions
Expressions are written in Java (language="java", the default) or Groovy (language="groovy"), as in
JasperReports, and give what JasperReports gives. They are interpreted from a fixed list of operations: a template cannot
load classes, read files or reach the network, and a Groovy expression that loops too long stops with an error.
JasperReports' function library, as Jaspersoft Studio's expression editor lists it, with JasperReports' results (checked case by case against JasperReports 6.20.6):
| Kind | Functions |
|---|---|
| Logical | IF, AND, OR, NOT, EQUALS, TRUE, FALSE |
| Math | ABS, SUM, PRODUCT, MAX, MIN, FLOOR, CEIL, SQRT, SIGN, FACT, ISEVEN, ISODD, RAND, RANDBETWEEN, ROUND_HALF_UP and the other ROUND_* modes |
| Text | LEFT, RIGHT, MID, LEN, FIND, SEARCH, SUBSTITUTE, REPLACE, REPT, TRIM, LTRIM, RTRIM, CLEAN, LOWER, UPPER, PROPER, CONCATENATE, EXACT, CHAR, CODE, BASE, T, DOUBLE_VALUE, INTEGER_VALUE... |
| Dates | DATE, TODAY, NOW, YEAR, MONTH, DAY, WEEKDAY, HOUR, DATEFORMAT, DATEVALUE, EDATE, WORKDAY, NETWORKDAYS, DAYS, WEEKS, MONTHS, YEARS, WEEKNUM, DAYSINMONTH, ISLEAPYEAR, TIME, DATERANGE |
DATERANGE("DAY"), "WEEK-1", "MONTH+2", "QUARTER", "SEMI", "YEAR" (relative to
the render's date) or "2026-03-05" / "2026-03-05 14:30:00" give a range with getStart() and
getEnd(); a DateRange parameter takes the same text, and $X{[GREATER, column, Range} and the other
$X{} clauses compare the column with the range's start or end as JasperReports does.
IF($F{balance} < 0, "Overdue", "OK")
DATEFORMAT(EDATE($F{issued}, 1), "dd/MM/yyyy")
SUBSTITUTE(PROPER($F{name}), " ", "_")
Groovy: lists, maps and ranges ([1, 2], [a: 1], 1..5); closures given to
findAll, find, collect, sum, max, min, sort,
any, every, count, inject, groupBy, collectEntries, each,
withIndex; strings with ${...}; ?., ?:, **, <=>, in,
as, list[i], text[0..2]; padLeft, padRight, center, tokenize,
capitalize, reverse, take, drop, toInteger, intdiv, round.
Groovy's arithmetic too: 5 / 2 is 2.5 and 1234.50 / 3 is 411.50.
$F{lines}.findAll { it.qty > 0 }.sum { it.qty * it.price }
"${$F{first}} ${$F{last}}".toUpperCase()
$F{tags}.collect { it.capitalize() }.join(", ")
Not supported: your own Java classes and scriptlets, and Groovy statements (def, loops, if blocks).
ferroreport doctor says so when a template uses them.
Check a template
Before you depend on a template, ask the engine what it thinks of it:
$ ferroreport doctor invoice.jrxml invoice.jrxml: report `invoice` page 595x842 pt, margins 30/40/30/40, language Java 5 parameters, 5 fields, 3 variables, 0 groups elements: line ×1, rectangle ×1, staticText ×9, textField ×17 ✓ every feature used by this template is supported
From code, inspect(template) (JavaScript, Python) and POST /inspect return the same verdict as data:
an empty warnings list means every feature in the template is supported.
Errors
A render either returns a complete PDF or fails with a message that names the cause. The usual ones:
| Message | What to do |
|---|---|
invalid report template | The text is not JRXML. Send the .jrxml source, not a compiled .jasper file |
cannot convert ... to ... | A value does not fit the class its field declares. See the table in Data |
| An expression error | The expression uses a Java class or method outside the supported subset. doctor points at it |
| An image or subreport is not found | Add its folder as a resource directory, or pass the file in resources |
Templates cannot run code, read files outside the resource folders or open network connections, so it is safe to render templates your users upload.
What is supported
Bands and page breaks, groups and variables, frames, images, subreports, tables (jr:table), lists (jr:list), crosstabs, every JasperReports chart type, barcodes (QR, DataMatrix, PDF417, Code 128, EAN-128, Code 39, EAN-13, EAN-8, UPC-A, UPC-E, Interleaved 2 of 5, Codabar, POSTNET, Royal Mail, USPS Intelligent Mail, and every type of the Barbecue component but PostNet), links, anchors and bookmarks, PDF form fields, icon labels, styled, HTML and RTF text,
rotation, multi-column layouts in either print order, conditional styles and style templates, PNG, JPEG, GIF and SVG images (RealHeight and RealSize too), data from JSON or SQL databases, Groovy expressions and JasperReports' function library, from JRXML 6, JRXML 7 or
.ferro templates, exported to PDF (tagged, PDF/UA-1; PDF/A-2 and PDF/A-3 with attachments; encrypted; signed), Excel, Word, CSV or HTML. The
compatibility table in the repository lists every
feature and what is not there yet, and ferroreport doctor gives the answer for your own template.