esc_pos_printer 1.3.0 copy "esc_pos_printer: ^1.3.0" to clipboard
esc_pos_printer: ^1.3.0 copied to clipboard

outdated

The library allows to print receipts using a ESC/POS (usually thermal) network printer. It can be used in Flutter or Dart projects. In Flutter, both Android and iOS are supported.

esc_pos_printer #

Pub

The library allows to print receipts using a ESC/POS (usually thermal) network printer.

[pub.dev page] | [Documentation]

It can be used in Flutter or Dart projects. In Flutter, both Android and iOS are supported.

To discover existing printers in your subnet, consider using ping_discover_network package. Note that most of ESC/POS printers by default listen on port 9100.

Features #

  • Connect to Wi-Fi printers
  • Simple text printing using println method
  • Tables printing using printRow method
  • Text styling:
    • size, align, bold, reverse, underline, different fonts
  • Paper cut (partial, full)
  • Beeping (with different duration)
  • Paper feed, reverse feed

Note: Your printer may not support some of presented features (especially for underline styles, partial/full paper cutting, reverse feed, ...).

Getting Started #

import 'package:esc_pos_printer/esc_pos_printer.dart';

Printer.connect('192.168.0.123', port: 9100).then((printer) {
    printer.println('Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
    printer.println('Special: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
        styles: PosStyles(codeTable: PosCodeTable.westEur));
    printer.println('Bold text', styles: PosStyles(bold: true));
    printer.println('Reverse text', styles: PosStyles(reverse: true));
    printer.println('Underlined text',
        styles: PosStyles(underline: true), linesAfter: 1);
    printer.println('Align left', styles: PosStyles(align: PosTextAlign.left));
    printer.println('Align center',
        styles: PosStyles(align: PosTextAlign.center));
    printer.println('Align right',
        styles: PosStyles(align: PosTextAlign.right), linesAfter: 1);
    
    printer.println('Text size 200%',
        styles: PosStyles(
          height: PosTextSize.size2,
          width: PosTextSize.size2,
        ));

    printer.cut();
    printer.disconnect();
  });

Print table row:

printer.printRow([
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosTextAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosTextAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosTextAlign.center, underline: true),
      ),
    ]);

Print image:

import 'dart:io';
import 'package:image/image.dart';

const String filename = './logo.png';
final Image image = decodeImage(File(filename).readAsBytesSync());
printer.printImage(image);

TODO #

  • Add raw print function
  • Print images
  • Print barcodes
  • Print QR codes
  • Turn 90° clockwise rotation mode on/off
  • Flutter example: discover active Wi-Fi printers
  • USB printers support
  • Add encoding commands
361
likes
0
pub points
96%
popularity

Publisher

verified publishertablemi.com

The library allows to print receipts using a ESC/POS (usually thermal) network printer. It can be used in Flutter or Dart projects. In Flutter, both Android and iOS are supported.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, hex, image, raw

More

Packages that depend on esc_pos_printer