printImage static method

Future<bool> printImage(
  1. String imagePath, {
  2. int width = 0,
  3. Alignment alignment = Alignment.centerLeft,
})

Print an image from a file path.

  • imagePath: Path to the image file
  • width: Width to resize the image (0 = printer default)
  • alignment: Image alignment (left, center, right)

Returns true if printing was successful.

Implementation

static Future<bool> printImage(
  String imagePath, {
  int width = 0,
  Alignment alignment = Alignment.centerLeft,
}) async {
  try {
    return await PrinterCore.printImage(
      imagePath,
      width: width,
      alignment: TextFormatter.convertAlignment(alignment),
    );
  } catch (e) {
    print('Error printing image: $e');
    return false;
  }
}