fajfield_reports

Invoices, statements and multi-page reports in pure Dart: designed visually, rendered offline to real-text PDF.

Design the report in the browser with the Fajfield report designer, export the template (.fjt), and render it in your app with your own data. You get a real-text PDF. It runs anywhere Dart runs (apps, servers, the command line), with no internet and almost no dependencies: the package has its own small PDF writer.

Building a Flutter app? Use fajfield_reports_flutter. It draws text with Flutter's engine, so every language prints, and adds an on-screen report view.

Designing an invoice in the Fajfield report designer

The rendered invoice Stock report, page 1 Stock report, page 2: the table header repeats

Above: the designer. Below: an invoice, and a 60-row stock report over two pages with its header repeated and "Page 2 of 2" filled in. Images are from the designer's preview, which uses the same layout rules as this package.

Why

The offline report engine mobile apps never had:

  • Like RDLC or Crystal Reports, but offline and cross-platform. The designer is the report builder; this package is the viewer that ships inside your app.
  • Change layouts without an app release. Templates are files. Load them from assets, or from your server.
  • Tables that continue across pages, with the header repeated, a totals row, and "Page x of y".
  • Real text in the PDF: selectable and searchable, with vector lines, sharp barcodes and pictures (PNG, JPEG).
  • Tiny and stable: dependencies are only barcode and Dart's own intl. No PDF library chain to break.
  • Global formats: A4, Letter, Legal or any size, plus any locale and currency ($1,234.50, 1.234,50 €). Text uses the standard PDF fonts (Helvetica, Times, Courier), which cover Latin scripts. For Malayalam, Hindi, Arabic, Chinese and others, use fajfield_reports_flutter.
  • Any database: pass a map, or plug in sqflite, drift, Hive, Isar or REST.
  • Never in the dark: every problem (a bad expression, missing data, an invalid barcode) comes back as a plain-language warning.

Install

dependencies:
  fajfield_reports: ^0.1.0

Render a report

import 'dart:io';
import 'package:fajfield_reports/fajfield_reports.dart';

final report = FjReport.fromJsonString(File('invoice.fjt').readAsStringSync());
final result = await ReportRenderer().render(report, data: {
  'company':  {'name': 'Harbour Foods Co.', 'address': '120 Harbour Road, Kochi'},
  'customer': {'name': 'Fresh Mart Supermarket', 'address': '14 Marine Drive, Dubai'},
  'invoice':  {'no': 'INV-2026-0451', 'date': '2026-11-28', 'due': '2026-12-12'},
  'items': [
    {'name': 'Coconut oil 1 L', 'qty': 2, 'rate': 4.5, 'taxRate': 0.05},
    {'name': 'Basmati rice 5 kg', 'qty': 1, 'rate': 18, 'taxRate': 0.05},
  ],
});

File('invoice.pdf').writeAsBytesSync(result.pdf);
print(result);   // pages, bytes, time and any warnings

Try it: dart run example/main.dart writes invoice.pdf from the sample template.

Design it in the browser

Open fajfield.com/designer/report. It's free to start and works like a desktop report builder:

Table columns, formats and totals in the designer

  • Bands: page header and footer on every page, a report header once, a body where tables grow, and a report footer after the last row (totals, notes, signatures).
  • Tools: text, table, chart (bar, line, pie), picture, line, rectangle, ellipse, barcode, QR code, page number, date, signature line. Click and draw, or drag onto the page.
  • Moving and editing: resize from every side, snap to grid and guides, multi-select, align and distribute, a right-click menu, copy and paste, undo.
  • Properties: fonts, alignment, rotation, borders, fill, padding, "show only if" rules, number formats and table totals. Sizes in mm, cm, inches or pixels.
  • Edit and View modes: View shows the real pages with sample data.
  • Export → Template (.fjt): that's the file this package renders. Add it to assets/ in pubspec.yaml.

Right-click menu in the designer View mode shows the real pages

Data

The template lists its datasets: lists (rows for tables and charts) and single records (company, customer, invoice). Pass a map with those names, or use a data source:

// sqflite, drift, Hive, Isar or anything else: one function per dataset
final source = QueryDataSource({
  'invoice': () async => (await db.query('invoices', where: 'id = ?', whereArgs: [id])).first,
  'items':   () => db.query('invoice_lines', where: 'invoice_id = ?', whereArgs: [id]),
  'company': () => Hive.box('settings').get('company'),
});
final result = await ReportRenderer().render(report, source: source);

Rows and objects are turned into plain data automatically. Objects with toJson() (drift, Isar, json_serializable) work as they are, and DateTime becomes an ISO date.

While building a screen: ReportRenderer(fillMissingWithSample: true) uses the template's sample data for anything you haven't passed yet.

Expressions

Anything in {{ }} is a field or a small, safe expression. It's parsed, never run as code.

Write Gives
{{customer.name}} a field (dots reach into nested data)
{{qty * rate * (1 + taxRate)}} maths: + - * / %
{{sum(items.qty * items.rate)}} sum, count, avg, min, max over a list
{{format(total, 'currency')}} currency, number, percent, date, datetime, 0.00, #,##0.00
{{qty < reorder ? 'Reorder' : 'OK'}} conditions; also if(a, b, c)
{{date(today)}}, {{upper(name)}}, {{round(x, 2)}} dates, text, rounding
Page {{page}} of {{pages}} page numbers (page header and footer)

Number and date formats follow the template's locale and currency, set in the designer under Report → Numbers and dates.

Fonts and languages

The PDF uses the standard fonts every PDF reader has, so files stay small and need no embedding. Template font names map to the closest one: Arial, Verdana and the like to Helvetica; Georgia and Times New Roman to Times; Courier New to Courier. Text is measured with the same font metrics the reader uses, so wrapping and page breaks are exact.

These fonts cover Latin scripts (English, French, German, Spanish, Portuguese, Indonesian…). The rupee sign prints as "Rs.". For other scripts, render in Flutter with fajfield_reports_flutter, which shapes text with Flutter's engine. The core renderer warns you if any text can't be shown.

Warnings: never in the dark

final result = await ReportRenderer().render(report, data: data);
if (result.hasWarnings) debugPrint(result.toString());
ReportResult(2 pages, 48211 bytes, 63 ms, 2 warnings:
  - No data for "customer". Pass it as data: {'customer': { ... }}.
  - {{ qty * }}: Unfinished expression)

Problems also show in place in the PDF as [message], so you can see exactly which field failed.

How pages are laid out

  1. Page header and footer on every page. The page header can skip page 1.
  2. Report header once, at the top of page 1.
  3. Body: tables add one row per item. When a row doesn't fit, the table continues on a new page with its header repeated. A row never splits, and the totals row stays with the last row.
  4. Report footer after the last row. It moves to a new page if it doesn't fit.
  5. Page numbers are filled in last, so "Page 2 of 5" is always right.

Example

dart run example/main.dart renders the sample invoice in test/assets/ with your data and writes invoice.pdf. For a full Flutter app with a gallery, an on-screen view, printing and a Malayalam invoice, see the example in fajfield_reports_flutter.

Status

0.1.0 is the first release. Open source under the MIT license, free for commercial apps. The designer is free to start, with advanced features in Fajfield Pro. Please report issues on GitHub with result.toString() attached.

Made by Fajfield: research and development for ERP, warehouse, POS and business data.

Libraries

fajfield_reports
Render invoices, statements and multi-page reports from Fajfield templates (.fjt) to PDF, offline, in pure Dart. Design the template at https://fajfield.com/designer/report/. For text in every language and an on-screen preview in Flutter, add fajfield_reports_flutter.