Commit 2005ed65 authored by Andrey's avatar Andrey

Updated changelog, pubspec version, readme

parent 6e94adc3
## [2.1.0]
* Printer class replaced by PrinterNetworkManager
* Generate tickets using Ticket class
* Unified interfaces for WiFi/Bluetooth printings
* Better error handling using PosPrintResult class
* Examples updated
## [2.0.0] ## [2.0.0]
* Bluetooth printers support (beta version, iOS-only) * Bluetooth printers support (beta version, iOS-only)
......
...@@ -9,7 +9,7 @@ The library allows to print receipts using an ESC/POS thermal WiFi/Bluetooth pri ...@@ -9,7 +9,7 @@ The library allows to print receipts using an ESC/POS thermal WiFi/Bluetooth pri
WiFi printing can be used in [Flutter](https://flutter.dev/) or pure [Dart](https://dart.dev/) projects. For Flutter projects, both Android and iOS are supported. WiFi printing can be used in [Flutter](https://flutter.dev/) or pure [Dart](https://dart.dev/) projects. For Flutter projects, both Android and iOS are supported.
Bluetooth printing can be used only for iOS. Android support will be added soon (I hope). Bluetooth printing can be used only for iOS. Android support will be added soon *(I hope)*.
To discover existing printers in your subnet, 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 discover existing printers in your subnet, 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.
...@@ -17,7 +17,7 @@ To discover existing printers in your subnet, consider using [ping_discover_netw ...@@ -17,7 +17,7 @@ To discover existing printers in your subnet, consider using [ping_discover_netw
* Connect to Wi-Fi / Bluetooth printers * Connect to Wi-Fi / Bluetooth printers
* Simple text printing using *text* method * Simple text printing using *text* method
* Tables printing using *printRow* method * Tables printing using *row* method
* Text styling: * Text styling:
* size, align, bold, reverse, underline, different fonts, turn 90° * size, align, bold, reverse, underline, different fonts, turn 90°
* Print images * Print images
...@@ -29,60 +29,58 @@ To discover existing printers in your subnet, consider using [ping_discover_netw ...@@ -29,60 +29,58 @@ To discover existing printers in your subnet, consider using [ping_discover_netw
**Note**: Your printer may not support some of the presented features (especially for underline styles, partial/full paper cutting, reverse feed, ...). **Note**: Your printer may not support some of the presented features (especially for underline styles, partial/full paper cutting, reverse feed, ...).
## Getting Started (WiFi printer) ## Getting started (Generate a ticket)
```dart ```dart
import 'package:esc_pos_printer/esc_pos_printer.dart'; Ticket testTicket() {
final Ticket ticket = Ticket(PaperSize.mm80);
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'); ticket.text(
printer.println('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ', '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');
styles: PosStyles(codeTable: PosCodeTable.westEur)); ticket.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
printer.println('Special 2: blåbærgrød', styles: PosStyles(codeTable: PosCodeTable.westEur));
styles: PosStyles(codeTable: PosCodeTable.westEur)); ticket.text('Special 2: blåbærgrød',
styles: PosStyles(codeTable: PosCodeTable.westEur));
printer.println('Bold text', styles: PosStyles(bold: true));
printer.println('Reverse text', styles: PosStyles(reverse: true)); ticket.text('Bold text', styles: PosStyles(bold: true));
printer.println('Underlined text', ticket.text('Reverse text', styles: PosStyles(reverse: true));
styles: PosStyles(underline: true), linesAfter: 1); ticket.text('Underlined text',
styles: PosStyles(underline: true), linesAfter: 1);
printer.println('Align left', styles: PosStyles(align: PosTextAlign.left)); ticket.text('Align left', styles: PosStyles(align: PosTextAlign.left));
printer.println('Align center', ticket.text('Align center', styles: PosStyles(align: PosTextAlign.center));
styles: PosStyles(align: PosTextAlign.center)); ticket.text('Align right',
printer.println('Align right', styles: PosStyles(align: PosTextAlign.right), linesAfter: 1);
styles: PosStyles(align: PosTextAlign.right), linesAfter: 1);
ticket.text('Text size 200%',
printer.println('Text size 200%', styles: PosStyles(
styles: PosStyles( height: PosTextSize.size2,
height: PosTextSize.size2, width: PosTextSize.size2,
width: PosTextSize.size2, ));
));
ticket.feed(2);
printer.cut(); ticket.cut();
printer.disconnect(); return ticket;
}); }
``` ```
Print table row: Print table row:
```dart ```dart
printer.printRow([ ticket.row([
PosColumn( PosColumn(
text: 'col3', text: 'col3',
width: 3, width: 3,
styles: PosStyles(align: PosTextAlign.center, underline: true), styles: PosStyles(align: PosTextAlign.center, underline: true),
), ),
PosColumn( PosColumn(
text: 'col6', text: 'col6',
width: 6, width: 6,
styles: PosStyles(align: PosTextAlign.center, underline: true), styles: PosStyles(align: PosTextAlign.center, underline: true),
), ),
PosColumn( PosColumn(
text: 'col3', text: 'col3',
width: 3, width: 3,
styles: PosStyles(align: PosTextAlign.center, underline: true), styles: PosStyles(align: PosTextAlign.center, underline: true),
), ),
]); ]);
``` ```
Print image: Print image:
...@@ -94,24 +92,52 @@ import 'package:image/image.dart'; ...@@ -94,24 +92,52 @@ import 'package:image/image.dart';
const String filename = './logo.png'; const String filename = './logo.png';
final Image image = decodeImage(File(filename).readAsBytesSync()); final Image image = decodeImage(File(filename).readAsBytesSync());
// Using (ESC *) command // Using (ESC *) command
printer.printImage(image); ticket.image(image);
// Using an alternative obsolette (GS v 0) command // Using an alternative obsolette (GS v 0) command
printer.printImageRaster(image); ticket.imageRaster(image);
``` ```
Print barcode: Print barcode:
```dart ```dart
final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4]; final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
printer.printBarcode(Barcode.upcA(barData)); ticket.barcode(Barcode.upcA(barData));
``` ```
## Getting Started (WiFi printer)
```dart
import 'package:esc_pos_printer/esc_pos_printer.dart';
final PrinterNetworkManager printerManager = PrinterNetworkManager();
printerManager.selectPrinter('192.168.0.123', port: 9100);
final PosPrintResult res = await printerManager.printTicket(testTicket());
print('Print result: ${PosPrintResult.msg(res)}');
```
For more details, check *example/example.dart* and *example/discover_printers*.
## Getting Started (Bluetooth printer) ## Getting Started (Bluetooth printer)
See example project *blue*.
```dart
PrinterBluetoothManager printerManager = PrinterBluetoothManager();
printerManager.scanResults.listen((printers) async {
// store found printers
});
printerManager.startScan(Duration(seconds: 4));
// ...
printerManager.selectPrinter(printer);
final PosPrintResult res = await printerManager.printTicket(testTicket());
print('Print result: ${PosPrintResult.msg(res)}');
```
For more details, check demo project *example/blue*.
## TODO ## TODO
* Bluetooth printers / add Android support * Bluetooth printers: add Android support
* WiFi printers / use Ticket class to make both, WiFi and Bluetooth interfaces more uniform
* WiFi printers / add 58mm and 80mm paper types
* Print QR codes * Print QR codes
* USB printers support * USB printers support
......
name: esc_pos_printer name: esc_pos_printer
description: The library allows to print receipts using an ESC/POS thermal WiFi/Bluetooth printer. description: The library allows to print receipts using an ESC/POS thermal WiFi/Bluetooth printer.
version: 2.0.0 version: 2.1.0
homepage: https://github.com/andrey-ushakov/esc_pos_printer homepage: https://github.com/andrey-ushakov/esc_pos_printer
environment: environment:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment