The library allows to print receipts using an ESC/POS thermal WiFi/Ethernet printer. For Bluetooth printers, use [esc_pos_bluetooth](https://github.com/andrey-ushakov/esc_pos_bluetooth) library.
The library allows to print receipts using an ESC/POS thermal WiFi/Ethernet printer. For Bluetooth printers, use [esc_pos_bluetooth](https://github.com/andrey-ushakov/esc_pos_bluetooth) library.
It can be used in [Flutter](https://flutter.dev/) or pure [Dart](https://dart.dev/) projects. For Flutter projects, both Android and iOS are supported.
It can be used in [Flutter](https://flutter.dev/) or pure [Dart](https://dart.dev/) projects. For Flutter projects, both Android and iOS are supported.
To scan for printers in your network, consider using [ping_discover_network](https://pub.dev/packages/ping_discover_network) package. Note that most of the ESC/POS printers by default listen on port 9100.
To scan for printers in your network, consider using [ping_discover_network](https://pub.dev/packages/ping_discover_network) package. Note that most of the ESC/POS printers by default listen on port 9100.
...
@@ -14,24 +11,11 @@ To scan for printers in your network, consider using [ping_discover_network](htt
...
@@ -14,24 +11,11 @@ To scan for printers in your network, consider using [ping_discover_network](htt
## Tested Printers
## Tested Printers
Here are some [printers tested with this library](printers.md). Please add your models you have tested to maintain and improve this library and help others to choose the right printer.
Here are some [printers tested with this library](printers.md). Please add your models you have tested to maintain and improve this library and help others to choose the right printer.
## Main Features
* Connect to Wi-Fi / Ethernet printers
* Simple text printing using *text* method
* Tables printing using *row* method
* Text styling:
* size, align, bold, reverse, underline, different fonts, turn 90°
**Note**: Your printer may not support some of the presented features (especially for underline styles, partial/full paper cutting, reverse feed, ...).
## Getting started: Generate a Ticket
## Generate a Ticket
### Simple ticket:
### Simple Ticket with Styles:
```dart
```dart
TickettestTicket(){
TickettestTicket(){
finalTicketticket=Ticket(PaperSize.mm80);
finalTicketticket=Ticket(PaperSize.mm80);
...
@@ -64,84 +48,10 @@ Ticket testTicket() {
...
@@ -64,84 +48,10 @@ Ticket testTicket() {
}
}
```
```
### Print a table row:
You can find more examples here: [esc_pos_utils](https://github.com/andrey-ushakov/esc_pos_utils).
To print a QR Code, add [qr_flutter](https://pub.dev/packages/qr_flutter) and [path_provider](https://pub.dev/packages/path_provider) as a dependency in your `pubspec.yaml` file.
@@ -152,61 +62,14 @@ final PosPrintResult res = await printerManager.printTicket(testTicket());
...
@@ -152,61 +62,14 @@ final PosPrintResult res = await printerManager.printTicket(testTicket());
print('Print result: ${res.msg}');
print('Print result: ${res.msg}');
```
```
For more details, check `example/example.dart` and `example/discover_printers`.
For a complete example, check `example/example.dart` and `example/discover_printers`.
## Using Code Tables
Thanks to the [charset_converter](https://pub.dev/packages/charset_converter) package, it's possible to print in different languages. The source text should be encoded using the corresponding charset and the correct charset should be passed to the `Ticket.textEncoded` method.
Here are some examples:
```dart
/// Portuguese
Uint8ListencTxt1=awaitCharsetConverter.encode(
"cp860","Portuguese: Olá, Não falo português, Cão");
Note that `CharsetConverter.encode` takes a platform-specific charset (check the [library documentation](https://pub.dev/packages/charset_converter) for more info).
Note that different printers may support different sets of codetables and the above examples may not work on some printer models. It's also possible to pass a codetable by its code (according to your printer's documentation): `PosStyles(codeTable: PosCodeTable(7))`.
## How to Help
* Test your printer and add it in the table: [Wifi/Network printer](https://github.com/andrey-ushakov/esc_pos_printer/blob/master/printers.md) or [Bluetooth printer](https://github.com/andrey-ushakov/esc_pos_bluetooth/blob/master/printers.md)
* Test and report bugs
* Share your ideas about what could be improved (code optimization, new features...)