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,
  6. OutputType outputType = OutputType.generic,
  7. bool forceCustomPrintPaper = 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)

Set outputType to OutputType.generic to use the default printing system, or OutputType.photos to use the photo printing system. (Supported platforms: iOS)

Use customPrintPaper to force the printer to use a custom paper size. Use value true to use format as custom paper size, when the printer driver will not allows the user to use papers which are actually supported by the printer. (Supported platforms: iOS)

Implementation

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