fajfield_reports 0.1.0
fajfield_reports: ^0.1.0 copied to clipboard
Render invoices, statements and multi-page reports from Fajfield templates (.fjt) to real-text PDF, offline, in pure Dart, with its own small PDF writer. Tables continue across pages.
// dart run example/main.dart
// Renders the sample invoice with your data to invoice.pdf (pure Dart: works on servers and the command line).
import 'dart:io';
import 'package:fajfield_reports/fajfield_reports.dart';
Future<void> main() async {
final report = FjReport.fromJsonString(File('test/assets/invoice.fjt').readAsStringSync());
final result = await ReportRenderer(fillMissingWithSample: true).render(report, data: {
'customer': {'name': 'Fresh Mart Supermarket', 'address': '14 Marine Drive\nDubai, United Arab Emirates'},
'invoice': {'no': 'INV-2026-0452', 'date': '2026-11-28', 'due': '2026-12-12', 'terms': 'Payment due within 14 days.'},
'items': [
{'name': 'Coconut oil 1 L', 'qty': 12, 'rate': 4.5, 'taxRate': 0.05},
{'name': 'Basmati rice 5 kg', 'qty': 4, 'rate': 18, 'taxRate': 0.05},
{'name': 'Green tea 100 bags', 'qty': 20, 'rate': 3.2, 'taxRate': 0.05},
],
});
File('invoice.pdf').writeAsBytesSync(result.pdf);
print(result); // pages, size, time and any warnings
}