layoutPdf static method

Future<bool> layoutPdf({
  1. required LayoutCallback onLayout,
  2. String name = 'Document',
  3. PdfPageFormat format = PdfPageFormat.standard,
  4. bool dynamicLayout = true,
  5. bool usePrinterSettings = false,
})

Prints a Pdf document to a local printer using the platform UI the Pdf document is re-built in a LayoutCallback each time the user changes a setting like the page format or orientation.

returns a future with a bool set to true if the document is printed and false if it is canceled. throws an exception in case of error

Set usePrinterSettings to true to use the configuration defined by the printer. May not work for all the printers and can depend on the drivers. (Supported platforms: Windows)

Implementation

static Future<bool> layoutPdf({
  required LayoutCallback onLayout,
  String name = 'Document',
  PdfPageFormat format = PdfPageFormat.standard,
  bool dynamicLayout = true,
  bool usePrinterSettings = false,
}) {
  return PrintingPlatform.instance.layoutPdf(
    null,
    onLayout,
    name,
    format,
    dynamicLayout,
    usePrinterSettings,
  );
}