buildPDF method

Future<Uint8List> buildPDF(
  1. PdfPageFormat pageFormat,
  2. DocumentOptions options
)

Implementation

Future<Uint8List> buildPDF(PdfPageFormat pageFormat, DocumentOptions options) async {
  final doc = pw.Document(); // Create a PDF document.
  //_logo = await rootBundle.loadString('assets/logo.svg');
  //_bgShape = await rootBundle.loadString('assets/invoice.svg');

  // Add page to the PDF
  doc.addPage(
    pw.Page(
      pageTheme: _buildTheme(
        pageFormat,
        await PdfGoogleFonts.robotoRegular(),
        await PdfGoogleFonts.robotoBold(),
        await PdfGoogleFonts.robotoItalic(),
      ),
      build: (context) => pw.Column(
        crossAxisAlignment: pw.CrossAxisAlignment.start,
        children: [
          _contentHeader(context, options),
          _contentBody(context, options),
        ]
      )
    ),
  );

  return doc.save(); // Return the PDF file content
}