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]
* 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
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.
......@@ -17,7 +17,7 @@ To discover existing printers in your subnet, consider using [ping_discover_netw
* Connect to Wi-Fi / Bluetooth printers
* Simple text printing using *text* method
* Tables printing using *printRow* method
* Tables printing using *row* method
* Text styling:
* size, align, bold, reverse, underline, different fonts, turn 90°
* Print images
......@@ -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, ...).
## Getting Started (WiFi printer)
## Getting started (Generate a ticket)
```dart
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 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
styles: PosStyles(codeTable: PosCodeTable.westEur));
printer.println('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));
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();
});
Ticket testTicket() {
final Ticket ticket = Ticket(PaperSize.mm80);
ticket.text(
'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('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
styles: PosStyles(codeTable: PosCodeTable.westEur));
ticket.text('Special 2: blåbærgrød',
styles: PosStyles(codeTable: PosCodeTable.westEur));
ticket.text('Bold text', styles: PosStyles(bold: true));
ticket.text('Reverse text', styles: PosStyles(reverse: true));
ticket.text('Underlined text',
styles: PosStyles(underline: true), linesAfter: 1);
ticket.text('Align left', styles: PosStyles(align: PosTextAlign.left));
ticket.text('Align center', styles: PosStyles(align: PosTextAlign.center));
ticket.text('Align right',
styles: PosStyles(align: PosTextAlign.right), linesAfter: 1);
ticket.text('Text size 200%',
styles: PosStyles(
height: PosTextSize.size2,
width: PosTextSize.size2,
));
ticket.feed(2);
ticket.cut();
return ticket;
}
```
Print table row:
```dart
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),
),
]);
ticket.row([
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:
......@@ -94,24 +92,52 @@ import 'package:image/image.dart';
const String filename = './logo.png';
final Image image = decodeImage(File(filename).readAsBytesSync());
// Using (ESC *) command
printer.printImage(image);
ticket.image(image);
// Using an alternative obsolette (GS v 0) command
printer.printImageRaster(image);
ticket.imageRaster(image);
```
Print barcode:
```dart
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)
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
* 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
* Bluetooth printers: add Android support
* Print QR codes
* USB printers support
......
name: esc_pos_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
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