Skip to content

Commit

Permalink
v2.0.9 : Open cash box and text style optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck ALARY committed Feb 12, 2021
1 parent 5736829 commit 9082adb
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 48 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![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)
[![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)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

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

## Installation

**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:
**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:

```
allprojects {
Expand All @@ -75,7 +75,7 @@ allprojects {
```
dependencies {
...
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.8'
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.9'
}
```

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

#### Method : `printFormattedTextAndOpenCashBox(String text, float mmFeedPaper)`
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.
- **param** `String text` : Formatted text to be printed.
- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.
- **return** `Printer` : Fluent interface

#### Method : `printFormattedText(String text, int dotsFeedPaper)`
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.
- **param** `String text` : Formatted text to be printed.
Expand All @@ -477,6 +483,12 @@ Print a formatted text, feed paper (`dotsFeedPaper` dots) and cut the paper. Rea
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
- **return** `Printer` : Fluent interface

#### Method : `printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper)`
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.
- **param** `String text` : Formatted text to be printed.
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
- **return** `Printer` : Fluent interface

#### Method : `bitmapToBytes(Bitmap bitmap)`
Convert Bitmap object to ESC/POS image.
- **param** `Bitmap bitmap` : Instance of Bitmap
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/com/dantsu/thermalprinter/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,30 +179,32 @@ public void printIt(DeviceConnection printerConnection) {
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
"[L]\n" +
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
"[C]<font size='small'>" + format.format(new Date()) + "</font>\n" +
"[L]\n" +
"[C]<u type='double'>" + format.format(new Date()) + "</u>\n" +
"[C]\n" +
"[C]================================\n" +
"[L]\n" +
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99€\n" +
"[L] + Size : S\n" +
"[L]\n" +
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
"[L]<b>AWESOME HAT</b>[R]24.99€\n" +
"[L] + Size : 57/58\n" +
"[L]\n" +
"[C]--------------------------------\n" +
"[R]TOTAL PRICE :[R]34.98e\n" +
"[R]TAX :[R]4.23e\n" +
"[R]TOTAL PRICE :[R]34.98€\n" +
"[R]TAX :[R]4.23€\n" +
"[L]\n" +
"[C]================================\n" +
"[L]\n" +
"[L]<font size='tall'>Customer :</font>\n" +
"[L]<u><font color='bg-black' size='tall'>Customer :</font></u>\n" +
"[L]Raymond DUPONT\n" +
"[L]5 rue des girafes\n" +
"[L]31547 PERPETES\n" +
"[L]Tel : +33801201456\n" +
"[L]\n" +
"\n" +
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
"[L]\n" +
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>\n"
);
} catch (EscPosConnectionException e) {
e.printStackTrace();
Expand Down Expand Up @@ -247,15 +249,15 @@ public AsyncEscPosPrinter getAsyncEscPosPrinter(DeviceConnection printerConnecti
"[C]\n" +
"[C]================================\n" +
"[L]\n" +
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99€\n" +
"[L] + Size : S\n" +
"[L]\n" +
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
"[L]<b>AWESOME HAT</b>[R]24.99€\n" +
"[L] + Size : 57/58\n" +
"[L]\n" +
"[C]--------------------------------\n" +
"[R]TOTAL PRICE :[R]34.98e\n" +
"[R]TAX :[R]4.23e\n" +
"[R]TOTAL PRICE :[R]34.98€\n" +
"[R]TAX :[R]4.23€\n" +
"[L]\n" +
"[C]================================\n" +
"[L]\n" +
Expand Down
18 changes: 15 additions & 3 deletions escposprinter/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![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)
[![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)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

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

## Installation

**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:
**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:

```
allprojects {
Expand All @@ -75,7 +75,7 @@ allprojects {
```
dependencies {
...
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.8'
implementation 'com.github.DantSu:ESCPOS-ThermalPrinter-Android:2.0.9'
}
```

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

#### Method : `printFormattedTextAndOpenCashBox(String text, float mmFeedPaper)`
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.
- **param** `String text` : Formatted text to be printed.
- **param** `float mmFeedPaper` : Millimeter distance feed paper at the end.
- **return** `Printer` : Fluent interface

#### Method : `printFormattedText(String text, int dotsFeedPaper)`
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.
- **param** `String text` : Formatted text to be printed.
Expand All @@ -477,6 +483,12 @@ Print a formatted text, feed paper (`dotsFeedPaper` dots) and cut the paper. Rea
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
- **return** `Printer` : Fluent interface

#### Method : `printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper)`
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.
- **param** `String text` : Formatted text to be printed.
- **param** `int dotsFeedPaper` : Distance feed paper at the end.
- **return** `Printer` : Fluent interface

#### Method : `bitmapToBytes(Bitmap bitmap)`
Convert Bitmap object to ESC/POS image.
- **param** `Bitmap bitmap` : Instance of Bitmap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,34 @@ public EscPosPrinter printFormattedTextAndCut(String text, int dotsFeedPaper) th
return this;
}

/**
* Print a formatted text, cut the paper and open the cash box. Read the README.md for more information about text formatting options.
*
* @param text Formatted text to be printed.
* @param mmFeedPaper millimeter distance feed paper at the end.
* @return Fluent interface
*/
public EscPosPrinter printFormattedTextAndOpenCashBox(String text, float mmFeedPaper) throws EscPosConnectionException, EscPosParserException, EscPosEncodingException, EscPosBarcodeException {
return this.printFormattedTextAndOpenCashBox(text, this.mmToPx(mmFeedPaper));
}

/**
* Print a formatted text, cut the paper and open the cash box. Read the README.md for more information about text formatting options.
*
* @param text Formatted text to be printed.
* @param dotsFeedPaper distance feed paper at the end.
* @return Fluent interface
*/
public EscPosPrinter printFormattedTextAndOpenCashBox(String text, int dotsFeedPaper) throws EscPosConnectionException, EscPosParserException, EscPosEncodingException, EscPosBarcodeException {
if (this.printer == null || this.printerNbrCharactersPerLine == 0) {
return this;
}

this.printFormattedTextAndCut(text, dotsFeedPaper);
this.printer.openCashBox();
return this;
}

/**
* @return Charset encoding
*/
Expand Down
Loading

0 comments on commit 9082adb

Please sign in to comment.