DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.42k stars 632 forks source link

Printing.directPrintPdf is not working for A5 (PdfPageFormat.a5) #1746

Open Doublelae opened 2 months ago

Doublelae commented 2 months ago

Describe the bug

To Reproduce Code snippet to reproduce the behavior:

   bool finish = false;
    try {
      for (int i = 0; i < copies; i++) {
        final data = await Printing.directPrintPdf(
          onLayout: (PdfPageFormat format) async => doc.save(),
          format: pageFormat ?? PdfPageFormat.a5,
          printer: printer,
          usePrinterSettings: true,    // princed A4 
        );
        if (!data) break;
        finish = i == copies - 1 && data;
        endpointsStream.add('printing copy no ---> $i  finished = $finish');
      }
    } catch (e, st) {
      finish = true;
      showCommonSnackBar(
        "Printer Error $e",
        backgroundColor: MyTheme.errorColor,
      );
      endpointsStream.add("print error = $e \n\n $st");
    }

Expected behavior

Screenshots

Flutter Doctor

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context