Skip to content

Commit 9082adb

Browse files
committed
v2.0.9 : Open cash box and text style optimization
1 parent 5736829 commit 9082adb

File tree

5 files changed

+140
-48
lines changed

5 files changed

+140
-48
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v2.0.8](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.8)
1+
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v2.0.9](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.9)
22
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33

44
# Android library for ESC/POS Thermal Printer
@@ -59,7 +59,7 @@ To test this library, it's pretty simple !
5959

6060
## Installation
6161

62-
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.8) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
62+
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.9) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
6363

6464
```
6565
allprojects {
@@ -75,7 +75,7 @@ allprojects {
7575
```
7676
dependencies {
7777
...
78-
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.8'
78+
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.9'
7979
}
8080
```
8181

@@ -465,6 +465,12 @@ Print a formatted text, feed paper (`mmFeedPaper` millimeters) and cut the paper
465465
- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.
466466
- **return** `Printer` : Fluent interface
467467

468+
#### Method : `printFormattedTextAndOpenCashBox(String text, float mmFeedPaper)`
469+
Print a formatted text, feed paper (`mmFeedPaper` millimeters), cut the paper and open the cash box. Read the ["Formatted Text : Syntax guide" section](#formatted-text--syntax-guide) for more information about text formatting options.
470+
- **param** `String text` : Formatted text to be printed.
471+
- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.
472+
- **return** `Printer` : Fluent interface
473+
468474
#### Method : `printFormattedText(String text, int dotsFeedPaper)`
469475
Print a formatted text and feed paper (`dotsFeedPaper` dots). Read the ["Formatted Text : Syntax guide" section](#formatted-text--syntax-guide) for more information about text formatting options.
470476
- **param** `String text` : Formatted text to be printed.
@@ -477,6 +483,12 @@ Print a formatted text, feed paper (`dotsFeedPaper` dots) and cut the paper. Rea
477483
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
478484
- **return** `Printer` : Fluent interface
479485

486+
#### Method : `printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper)`
487+
Print a formatted text, feed paper (`dotsFeedPaper` dots), cut the paper and open the cash box. Read the ["Formatted Text : Syntax guide" section](#formatted-text--syntax-guide) for more information about text formatting options.
488+
- **param** `String text` : Formatted text to be printed.
489+
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
490+
- **return** `Printer` : Fluent interface
491+
480492
#### Method : `bitmapToBytes(Bitmap bitmap)`
481493
Convert Bitmap object to ESC/POS image.
482494
- **param** `Bitmap bitmap` : Instance of Bitmap

app/src/main/java/com/dantsu/thermalprinter/MainActivity.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,30 +179,32 @@ public void printIt(DeviceConnection printerConnection) {
179179
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
180180
"[L]\n" +
181181
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
182-
"[C]<font size='small'>" + format.format(new Date()) + "</font>\n" +
183182
"[L]\n" +
183+
"[C]<u type='double'>" + format.format(new Date()) + "</u>\n" +
184+
"[C]\n" +
184185
"[C]================================\n" +
185186
"[L]\n" +
186-
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
187+
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99€\n" +
187188
"[L] + Size : S\n" +
188189
"[L]\n" +
189-
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
190+
"[L]<b>AWESOME HAT</b>[R]24.99€\n" +
190191
"[L] + Size : 57/58\n" +
191192
"[L]\n" +
192193
"[C]--------------------------------\n" +
193-
"[R]TOTAL PRICE :[R]34.98e\n" +
194-
"[R]TAX :[R]4.23e\n" +
194+
"[R]TOTAL PRICE :[R]34.98€\n" +
195+
"[R]TAX :[R]4.23€\n" +
195196
"[L]\n" +
196197
"[C]================================\n" +
197198
"[L]\n" +
198-
"[L]<font size='tall'>Customer :</font>\n" +
199+
"[L]<u><font color='bg-black' size='tall'>Customer :</font></u>\n" +
199200
"[L]Raymond DUPONT\n" +
200201
"[L]5 rue des girafes\n" +
201202
"[L]31547 PERPETES\n" +
202203
"[L]Tel : +33801201456\n" +
203-
"[L]\n" +
204+
"\n" +
204205
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
205-
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
206+
"[L]\n" +
207+
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>\n"
206208
);
207209
} catch (EscPosConnectionException e) {
208210
e.printStackTrace();
@@ -247,15 +249,15 @@ public AsyncEscPosPrinter getAsyncEscPosPrinter(DeviceConnection printerConnecti
247249
"[C]\n" +
248250
"[C]================================\n" +
249251
"[L]\n" +
250-
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
252+
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99€\n" +
251253
"[L] + Size : S\n" +
252254
"[L]\n" +
253-
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
255+
"[L]<b>AWESOME HAT</b>[R]24.99€\n" +
254256
"[L] + Size : 57/58\n" +
255257
"[L]\n" +
256258
"[C]--------------------------------\n" +
257-
"[R]TOTAL PRICE :[R]34.98e\n" +
258-
"[R]TAX :[R]4.23e\n" +
259+
"[R]TOTAL PRICE :[R]34.98€\n" +
260+
"[R]TAX :[R]4.23€\n" +
259261
"[L]\n" +
260262
"[C]================================\n" +
261263
"[L]\n" +

escposprinter/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v2.0.8](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.8)
1+
[![Jitpack package repository - ESCPOS-ThermalPrinter-Android v2.0.9](https://jitpack.io/v/DantSu/ESCPOS-ThermalPrinter-Android.svg)](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.9)
22
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33

44
# Android library for ESC/POS Thermal Printer
@@ -59,7 +59,7 @@ To test this library, it's pretty simple !
5959

6060
## Installation
6161

62-
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.8) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
62+
**Step 1.** Add the [JitPack](https://jitpack.io/#DantSu/ESCPOS-ThermalPrinter-Android/2.0.9) repository to your build file. Add it in your root `/build.gradle` at the end of repositories:
6363

6464
```
6565
allprojects {
@@ -75,7 +75,7 @@ allprojects {
7575
```
7676
dependencies {
7777
...
78-
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.8'
78+
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.9'
7979
}
8080
```
8181

@@ -465,6 +465,12 @@ Print a formatted text, feed paper (`mmFeedPaper` millimeters) and cut the paper
465465
- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.
466466
- **return** `Printer` : Fluent interface
467467

468+
#### Method : `printFormattedTextAndOpenCashBox(String text, float mmFeedPaper)`
469+
Print a formatted text, feed paper (`mmFeedPaper` millimeters), cut the paper and open the cash box. Read the ["Formatted Text : Syntax guide" section](#formatted-text--syntax-guide) for more information about text formatting options.
470+
- **param** `String text` : Formatted text to be printed.
471+
- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.
472+
- **return** `Printer` : Fluent interface
473+
468474
#### Method : `printFormattedText(String text, int dotsFeedPaper)`
469475
Print a formatted text and feed paper (`dotsFeedPaper` dots). Read the ["Formatted Text : Syntax guide" section](#formatted-text--syntax-guide) for more information about text formatting options.
470476
- **param** `String text` : Formatted text to be printed.
@@ -477,6 +483,12 @@ Print a formatted text, feed paper (`dotsFeedPaper` dots) and cut the paper. Rea
477483
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
478484
- **return** `Printer` : Fluent interface
479485

486+
#### Method : `printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper)`
487+
Print a formatted text, feed paper (`dotsFeedPaper` dots), cut the paper and open the cash box. Read the ["Formatted Text : Syntax guide" section](#formatted-text--syntax-guide) for more information about text formatting options.
488+
- **param** `String text` : Formatted text to be printed.
489+
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
490+
- **return** `Printer` : Fluent interface
491+
480492
#### Method : `bitmapToBytes(Bitmap bitmap)`
481493
Convert Bitmap object to ESC/POS image.
482494
- **param** `Bitmap bitmap` : Instance of Bitmap

escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinter.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,34 @@ public EscPosPrinter printFormattedTextAndCut(String text, int dotsFeedPaper) th
168168
return this;
169169
}
170170

171+
/**
172+
* Print a formatted text, cut the paper and open the cash box. Read the README.md for more information about text formatting options.
173+
*
174+
* @param text Formatted text to be printed.
175+
* @param mmFeedPaper millimeter distance feed paper at the end.
176+
* @return Fluent interface
177+
*/
178+
public EscPosPrinter printFormattedTextAndOpenCashBox(String text, float mmFeedPaper) throws EscPosConnectionException, EscPosParserException, EscPosEncodingException, EscPosBarcodeException {
179+
return this.printFormattedTextAndOpenCashBox(text, this.mmToPx(mmFeedPaper));
180+
}
181+
182+
/**
183+
* Print a formatted text, cut the paper and open the cash box. Read the README.md for more information about text formatting options.
184+
*
185+
* @param text Formatted text to be printed.
186+
* @param dotsFeedPaper distance feed paper at the end.
187+
* @return Fluent interface
188+
*/
189+
public EscPosPrinter printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper) throws EscPosConnectionException, EscPosParserException, EscPosEncodingException, EscPosBarcodeException {
190+
if (this.printer == null || this.printerNbrCharactersPerLine == 0) {
191+
return this;
192+
}
193+
194+
this.printFormattedTextAndCut(text, dotsFeedPaper);
195+
this.printer.openCashBox();
196+
return this;
197+
}
198+
171199
/**
172200
* @return Charset encoding
173201
*/

0 commit comments

Comments
 (0)