generateDoc method

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

This functions generates the document

Implementation

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