generateDoc method

  1. @override
Future<Document> generateDoc()
override

This functions generates the document

Implementation

@override
Future<pw.Document> generateDoc() async {
  final pw.Document pdf = pw.Document(
    compress: true,
    verbose: true,
    pageMode: PdfPageMode.outlines,
    version: PdfVersion.pdf_1_5,
  );
  final PdfPageFormat pageFormat = PdfPageFormat(_width, _height,
      marginBottom: _marginBottom,
      marginLeft: _marginLeft,
      marginRight: _marginRight,
      marginTop: _marginTop);
  // front matter
  final List<Map<String, dynamic>> docWidgets = await generatePages(
      documents: <Delta>[frontM ?? Delta(), document, backM ?? Delta()]);
  for (int i = 0; i < docWidgets.length; i++) {
    final Map<String, dynamic> map = docWidgets.elementAt(i);
    final List<pw.Widget> widgets = map['content'] as List<pw.Widget>;
    pdf.addPage(
      pw.MultiPage(
        theme: defaultTheme,
        pageFormat: pageFormat,
        maxPages: 99999999,
        build: (pw.Context context) {
          return <pw.Widget>[...widgets];
        },
      ),
    );
  }
  return pdf;
}