Skip to content

Commit 68a2e05

Browse files
committed
Adding flutter bridge link in doc
1 parent a7fc0dc commit 68a2e05

2 files changed

Lines changed: 73 additions & 71 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ Convert hexadecimal string of the image data to bytes ESC/POS command.
557557
- [AllInOneYT/react-native-thermal-printer : A React Native bridge](https://github.com/AllInOneYT/react-native-thermal-printer)
558558
- [paystory-de/thermal-printer-cordova-plugin : A Cordova / Ionic bridge](https://github.com/paystory-de/thermal-printer-cordova-plugin)
559559
- [asukiaaa/react-native-escpos-android : A React Native bridge](https://github.com/asukiaaa/react-native-escpos-android)
560+
- [android_bluetooth_printer : A Flutter bridge](https://pub.dev/packages/android_bluetooth_printer)
560561

561562
## Contributing
562563

escposprinter/README.md

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ Also, you have to check the bluetooth permission in your app like this :
9090

9191
```java
9292
if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) {
93-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH}, MainActivity.PERMISSION_BLUETOOTH);
94-
} else if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) {
95-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_ADMIN}, MainActivity.PERMISSION_BLUETOOTH_ADMIN);
96-
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
97-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, MainActivity.PERMISSION_BLUETOOTH_CONNECT);
98-
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
99-
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_SCAN}, MainActivity.PERMISSION_BLUETOOTH_SCAN);
100-
} else {
101-
// Your code HERE
102-
}
93+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH}, MainActivity.PERMISSION_BLUETOOTH);
94+
} else if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) {
95+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_ADMIN}, MainActivity.PERMISSION_BLUETOOTH_ADMIN);
96+
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
97+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, MainActivity.PERMISSION_BLUETOOTH_CONNECT);
98+
} else if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S && ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
99+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_SCAN}, MainActivity.PERMISSION_BLUETOOTH_SCAN);
100+
} else {
101+
// Your code HERE
102+
}
103103
```
104104

105105
### Bluetooth code example
@@ -108,8 +108,8 @@ The code below is an example to write in your activity :
108108

109109
```java
110110
EscPosPrinter printer = new EscPosPrinter(BluetoothPrintersConnections.selectFirstPaired(), 203, 48f, 32);
111-
printer
112-
.printFormattedText(
111+
printer
112+
.printFormattedText(
113113
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM))+"</img>\n" +
114114
"[L]\n" +
115115
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
@@ -136,7 +136,7 @@ printer
136136
"[L]\n" +
137137
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
138138
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
139-
);
139+
);
140140
```
141141

142142
Below a picture of the receipt printed with the code above :
@@ -155,43 +155,43 @@ The code below is an example to write in your activity :
155155

156156
```java
157157
new Thread(new Runnable() {
158-
public void run() {
158+
public void run() {
159159
try {
160-
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.3", 9300, 15), 203, 48f, 32);
161-
printer
162-
.printFormattedText(
163-
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
164-
"[L]\n" +
165-
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
166-
"[L]\n" +
167-
"[C]================================\n" +
168-
"[L]\n" +
169-
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
170-
"[L] + Size : S\n" +
171-
"[L]\n" +
172-
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
173-
"[L] + Size : 57/58\n" +
174-
"[L]\n" +
175-
"[C]--------------------------------\n" +
176-
"[R]TOTAL PRICE :[R]34.98e\n" +
177-
"[R]TAX :[R]4.23e\n" +
178-
"[L]\n" +
179-
"[C]================================\n" +
180-
"[L]\n" +
181-
"[L]<font size='tall'>Customer :</font>\n" +
182-
"[L]Raymond DUPONT\n" +
183-
"[L]5 rue des girafes\n" +
184-
"[L]31547 PERPETES\n" +
185-
"[L]Tel : +33801201456\n" +
186-
"[L]\n" +
187-
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
188-
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
189-
);
160+
EscPosPrinter printer = new EscPosPrinter(new TcpConnection("192.168.1.3", 9300, 15), 203, 48f, 32);
161+
printer
162+
.printFormattedText(
163+
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM)) + "</img>\n" +
164+
"[L]\n" +
165+
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
166+
"[L]\n" +
167+
"[C]================================\n" +
168+
"[L]\n" +
169+
"[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
170+
"[L] + Size : S\n" +
171+
"[L]\n" +
172+
"[L]<b>AWESOME HAT</b>[R]24.99e\n" +
173+
"[L] + Size : 57/58\n" +
174+
"[L]\n" +
175+
"[C]--------------------------------\n" +
176+
"[R]TOTAL PRICE :[R]34.98e\n" +
177+
"[R]TAX :[R]4.23e\n" +
178+
"[L]\n" +
179+
"[C]================================\n" +
180+
"[L]\n" +
181+
"[L]<font size='tall'>Customer :</font>\n" +
182+
"[L]Raymond DUPONT\n" +
183+
"[L]5 rue des girafes\n" +
184+
"[L]31547 PERPETES\n" +
185+
"[L]Tel : +33801201456\n" +
186+
"[L]\n" +
187+
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
188+
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
189+
);
190190
} catch (Exception e) {
191-
e.printStackTrace();
191+
e.printStackTrace();
192192
}
193-
}
194-
}).start();
193+
}
194+
}).start();
195195
```
196196

197197
## USB
@@ -205,37 +205,37 @@ You have to check the USB permission in your app like this :
205205
```java
206206
private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
207207
private final BroadcastReceiver usbReceiver = new BroadcastReceiver() {
208-
public void onReceive(Context context, Intent intent) {
208+
public void onReceive(Context context, Intent intent) {
209209
String action = intent.getAction();
210210
if (MainActivity.ACTION_USB_PERMISSION.equals(action)) {
211-
synchronized (this) {
212-
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
213-
UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
214-
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
215-
if (usbManager != null && usbDevice != null) {
216-
// YOUR PRINT CODE HERE
217-
}
218-
}
219-
}
211+
synchronized (this) {
212+
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
213+
UsbDevice usbDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
214+
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
215+
if (usbManager != null && usbDevice != null) {
216+
// YOUR PRINT CODE HERE
220217
}
221-
}
222-
};
218+
}
219+
}
220+
}
221+
}
222+
};
223223

224224
public void printUsb() {
225-
UsbConnection usbConnection = UsbPrintersConnections.selectFirstConnected(this);
226-
UsbManager usbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
227-
if (usbConnection != null && usbManager != null) {
225+
UsbConnection usbConnection = UsbPrintersConnections.selectFirstConnected(this);
226+
UsbManager usbManager = (UsbManager) this.getSystemService(Context.USB_SERVICE);
227+
if (usbConnection != null && usbManager != null) {
228228
PendingIntent permissionIntent = PendingIntent.getBroadcast(
229-
this,
230-
0,
231-
new Intent(MainActivity.ACTION_USB_PERMISSION),
232-
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0
229+
this,
230+
0,
231+
new Intent(MainActivity.ACTION_USB_PERMISSION),
232+
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ? PendingIntent.FLAG_MUTABLE : 0
233233
);
234234
IntentFilter filter = new IntentFilter(MainActivity.ACTION_USB_PERMISSION);
235235
registerReceiver(this.usbReceiver, filter);
236236
usbManager.requestPermission(usbConnection.getDevice(), permissionIntent);
237-
}
238-
}
237+
}
238+
}
239239
```
240240

241241
### USB code example
@@ -244,8 +244,8 @@ The code below is an example to write in your activity :
244244

245245
```java
246246
EscPosPrinter printer = new EscPosPrinter(new UsbConnection(usbManager, usbDevice), 203, 48f, 32);
247-
printer
248-
.printFormattedText(
247+
printer
248+
.printFormattedText(
249249
"[C]<img>" + PrinterTextParserImg.bitmapToHexadecimalString(printer, this.getApplicationContext().getResources().getDrawableForDensity(R.drawable.logo, DisplayMetrics.DENSITY_MEDIUM))+"</img>\n" +
250250
"[L]\n" +
251251
"[C]<u><font size='big'>ORDER N°045</font></u>\n" +
@@ -272,7 +272,7 @@ printer
272272
"[L]\n" +
273273
"[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
274274
"[C]<qrcode size='20'>http://www.developpeur-web.dantsu.com/</qrcode>"
275-
);
275+
);
276276
```
277277

278278

@@ -557,6 +557,7 @@ Convert hexadecimal string of the image data to bytes ESC/POS command.
557557
- [AllInOneYT/react-native-thermal-printer : A React Native bridge](https://github.com/AllInOneYT/react-native-thermal-printer)
558558
- [paystory-de/thermal-printer-cordova-plugin : A Cordova / Ionic bridge](https://github.com/paystory-de/thermal-printer-cordova-plugin)
559559
- [asukiaaa/react-native-escpos-android : A React Native bridge](https://github.com/asukiaaa/react-native-escpos-android)
560+
- [android_bluetooth_printer : A Flutter bridge](https://pub.dev/packages/android_bluetooth_printer)
560561

561562
## Contributing
562563

0 commit comments

Comments
 (0)