printPDF method

  1. @override
Future<bool?> printPDF(
  1. String filePath,
  2. int rotationDegrees,
  3. int copies,
  4. String cutOption,
  5. bool isCollated,
  6. bool printTrailer,
)
override

printPDF() asynchronously sends a print job of the currently set PDF to the printer that the app is currently connected to and returns a Boolean value afterwards with the result of the print operation (i.e. success or failure).

Implementation

@override
Future<bool?> printPDF(String filePath, int rotationDegrees, int copies,
    String cutOption, bool isCollated, bool printTrailer) async {
  final fileData = await rootBundle.load(filePath);
  final bytes = fileData.buffer.asUint8List();
  var sendMap = <String, dynamic>{
    "fileData": bytes,
    "rotationDegrees": rotationDegrees,
    "copies": copies,
    "cutOption": cutOption,
    "isCollated": isCollated,
    "printTrailer": printTrailer
  };
  bool? printed = await methodChannel.invokeMethod<bool>('printPDF', sendMap);
  return printed;
}