exportToPDF method
Implementation
Future<Uint8List?> exportToPDF() async {
if (stateManager == null) return null;
// This ensures we have built out all rows
buildAllRows();
// filter the list
var list = applyFilters(rows);
// sort the list
list = applySort(list);
// serialize the list
List<List<String?>> serialized = [];
for (var row in list) {
serialized.add(getSerializedRow(stateManager!, row));
}
// get the fonts
//final fontRegular = await rootBundle.load('assets/fonts/open_sans/OpenSans-Regular.ttf');
//final fontBold = await rootBundle.load('assets/fonts/open_sans/OpenSans-Bold.ttf');
//final themeData = pluto_grid_export.ThemeData.withFont(base: pluto_grid_export.Font.ttf(fontRegular), bold: pluto_grid_export.Font.ttf(fontBold));
// build the theme
final themeData = pluto_grid_export.ThemeData.base();
// these should be passed not hard coded
var title = "Table Export";
var creator = "Futter Markup Language";
var format = pluto_grid_export.PdfPageFormat.a4.landscape;
// generate the report
var bytes = pluto_grid_export.GenericPdfController(
title: title,
creator: creator,
format: format,
columns: getColumnTitles(stateManager!),
rows: serialized,
themeData: themeData,
).generatePdf();
return bytes;
}