react-native-earl-thermal-printer 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +58 -9
- package/android/.classpath +6 -0
- package/android/.project +28 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +2 -0
- package/android/build/.transforms/01d27a401e27226770afe5d01de80a4b/results.bin +1 -0
- package/android/build/.transforms/1861b00fc7aef98f3b52e5f126b2142f/results.bin +1 -0
- package/android/build/.transforms/1861b00fc7aef98f3b52e5f126b2142f/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/be6909eb75c4fe10baeb7def8f107123/results.bin +1 -0
- package/android/build/.transforms/fd003f6142b240a78eb754d45552561d/results.bin +1 -0
- package/android/build/.transforms/fd003f6142b240a78eb754d45552561d/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +1 -1
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +1 -1
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +1 -1
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +10 -10
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +20 -20
- package/android/src/main/java/com/pinmi/react/printer/RNBLEPrinterModule.java +4 -4
- package/android/src/main/java/com/pinmi/react/printer/RNNetPrinterModule.java +4 -4
- package/android/src/main/java/com/pinmi/react/printer/RNPrinterModule.java +2 -2
- package/android/src/main/java/com/pinmi/react/printer/RNUSBPrinterModule.java +4 -4
- package/android/src/main/java/com/pinmi/react/printer/adapter/BLEPrinterAdapter.java +17 -15
- package/android/src/main/java/com/pinmi/react/printer/adapter/NetPrinterAdapter.java +17 -15
- package/android/src/main/java/com/pinmi/react/printer/adapter/PrinterAdapter.java +2 -2
- package/android/src/main/java/com/pinmi/react/printer/adapter/USBPrinterAdapter.java +17 -15
- package/dist/NativeBLEPrinter.d.ts +2 -2
- package/dist/NativeBLEPrinter.d.ts.map +1 -1
- package/dist/NativeNetPrinter.d.ts +2 -2
- package/dist/NativeNetPrinter.d.ts.map +1 -1
- package/dist/NativeUSBPrinter.d.ts +2 -2
- package/dist/NativeUSBPrinter.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/ios/RNBLEPrinter.mm +4 -1
- package/ios/RNNetPrinter.mm +4 -1
- package/ios/RNUSBPrinter.mm +2 -0
- package/package.json +1 -1
- package/src/NativeBLEPrinter.ts +2 -2
- package/src/NativeNetPrinter.ts +2 -2
- package/src/NativeUSBPrinter.ts +2 -2
- package/src/index.ts +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright (c) 2026 Rin
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# react-native-earl-thermal-printer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
4
7
|
|
|
5
|
-
A
|
|
8
|
+
A React Native library for USB, Bluetooth (BLE), and Network (TCP/IP) thermal receipt printers. Modern, high-performance thermal printer library for React Native. Built with the New Architecture (TurboModules) for synchronous communication, zero legacy bridge overhead, and Android 12+ Bluetooth compliance.
|
|
6
9
|
|
|
7
10
|
Built for the **React Native New Architecture** (TurboModules / Codegen). Supports Android and iOS.
|
|
8
11
|
|
|
@@ -70,6 +73,8 @@ const devices = await USBPrinter.getDeviceList();
|
|
|
70
73
|
await USBPrinter.connectPrinter(devices[0].vendor_id, devices[0].product_id);
|
|
71
74
|
await USBPrinter.printText("Hello from USB!\n");
|
|
72
75
|
await USBPrinter.printBill("Receipt line\n");
|
|
76
|
+
await USBPrinter.printImage("https://example.com/logo.png", 300);
|
|
77
|
+
await USBPrinter.printQrCode("https://example.com", 200);
|
|
73
78
|
USBPrinter.closeConn();
|
|
74
79
|
```
|
|
75
80
|
|
|
@@ -81,6 +86,8 @@ const devices = await BLEPrinter.getDeviceList();
|
|
|
81
86
|
await BLEPrinter.connectPrinter(devices[0].inner_mac_address);
|
|
82
87
|
await BLEPrinter.printText("Hello from BLE!\n");
|
|
83
88
|
await BLEPrinter.printBill("Receipt line\n");
|
|
89
|
+
await BLEPrinter.printImage("https://example.com/logo.png", 300);
|
|
90
|
+
await BLEPrinter.printQrCode("https://example.com", 200);
|
|
84
91
|
BLEPrinter.closeConn();
|
|
85
92
|
```
|
|
86
93
|
|
|
@@ -99,6 +106,8 @@ const devices = await NetPrinter.getDeviceList();
|
|
|
99
106
|
await NetPrinter.connectPrinter("192.168.1.100", 9100);
|
|
100
107
|
await NetPrinter.printText("Hello from Network!\n");
|
|
101
108
|
await NetPrinter.printBill("Receipt line\n");
|
|
109
|
+
await NetPrinter.printImage("https://example.com/logo.png", 300);
|
|
110
|
+
await NetPrinter.printQrCode("https://example.com", 200);
|
|
102
111
|
NetPrinter.closeConn();
|
|
103
112
|
```
|
|
104
113
|
|
|
@@ -134,13 +143,13 @@ Print a text string using ESC/POS encoding. Supports formatting tags (see below)
|
|
|
134
143
|
|
|
135
144
|
Same as `printText` but defaults `beep`, `cut`, and `tailingLine` to `true`.
|
|
136
145
|
|
|
137
|
-
### `printImage(imageUrl: string): Promise<void>`
|
|
146
|
+
### `printImage(imageUrl: string, imageWidth?: number): Promise<void>`
|
|
138
147
|
|
|
139
|
-
Print an image from a URL.
|
|
148
|
+
Print an image from a URL. The optional `imageWidth` parameter controls the maximum width in pixels for the printed image (default: `200` on Android, `150` on iOS).
|
|
140
149
|
|
|
141
|
-
### `printQrCode(qrCode: string): Promise<void>`
|
|
150
|
+
### `printQrCode(qrCode: string, qrSize?: number): Promise<void>`
|
|
142
151
|
|
|
143
|
-
Print a QR code.
|
|
152
|
+
Print a QR code. The optional `qrSize` parameter controls the size in pixels of the generated QR code (default: `250`).
|
|
144
153
|
|
|
145
154
|
### `closeConn(): void`
|
|
146
155
|
|
|
@@ -348,7 +357,7 @@ export default function ThermalPrinterTest() {
|
|
|
348
357
|
|
|
349
358
|
try {
|
|
350
359
|
// To print a QR code:
|
|
351
|
-
await BLEPrinter.printQrCode("ZAM-OC-0001");
|
|
360
|
+
await BLEPrinter.printQrCode("ZAM-OC-0001", 100); // qrSize
|
|
352
361
|
// Print formatted receipt text (beeps + cuts automatically)
|
|
353
362
|
const bill =
|
|
354
363
|
"--------------------------------\n" +
|
|
@@ -361,8 +370,9 @@ export default function ThermalPrinterTest() {
|
|
|
361
370
|
|
|
362
371
|
// To print an image from URL:
|
|
363
372
|
// await BLEPrinter.printImage(
|
|
364
|
-
|
|
365
|
-
|
|
373
|
+
"https://images.unsplash.com/photo-1771258052747-52e19364185f?q=80&w=765&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
|
|
374
|
+
300, // imageWidth
|
|
375
|
+
);
|
|
366
376
|
} catch (err) {
|
|
367
377
|
console.warn("Print error:", err);
|
|
368
378
|
Alert.alert("Print Error", String(err));
|
|
@@ -417,6 +427,45 @@ const styles = StyleSheet.create({
|
|
|
417
427
|
|
|
418
428
|
---
|
|
419
429
|
|
|
430
|
+
## Running the Example
|
|
431
|
+
|
|
432
|
+
A working example app lives in the `example/` directory.
|
|
433
|
+
|
|
434
|
+
### Prerequisites
|
|
435
|
+
|
|
436
|
+
- [Node.js](https://nodejs.org/) (>= 18)
|
|
437
|
+
- [Yarn](https://classic.yarnpkg.com/) (v1) — required because the example uses `link:..`
|
|
438
|
+
- Android Studio with an emulator or a physical device (USB debugging enabled)
|
|
439
|
+
- For iOS: Xcode with CocoaPods
|
|
440
|
+
|
|
441
|
+
### Setup & Run
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
# 1. Install root dependencies
|
|
445
|
+
yarn install
|
|
446
|
+
|
|
447
|
+
# 2. Install example dependencies
|
|
448
|
+
cd example
|
|
449
|
+
yarn install
|
|
450
|
+
|
|
451
|
+
# 3. Run on Android
|
|
452
|
+
yarn android
|
|
453
|
+
|
|
454
|
+
# 4. (iOS) Install pods, then run
|
|
455
|
+
cd ios && pod install && cd ..
|
|
456
|
+
yarn ios
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
> **Windows users:** If the build fails with a `mkdir` / path error, the project path is too long for CMake. Use `subst` to shorten it:
|
|
460
|
+
>
|
|
461
|
+
> ```powershell
|
|
462
|
+
> subst P: "C:\path\to\react-native-thermal-receipt-printer"
|
|
463
|
+
> cd P:\example\android
|
|
464
|
+
> .\gradlew.bat app:assembleDebug
|
|
465
|
+
> ```
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
420
469
|
## New Architecture
|
|
421
470
|
|
|
422
471
|
This library is built for the React Native **New Architecture** using TurboModules and Codegen. It requires:
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<classpath>
|
|
3
|
+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17/"/>
|
|
4
|
+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
|
5
|
+
<classpathentry kind="output" path="bin/default"/>
|
|
6
|
+
</classpath>
|
package/android/.project
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name>react-native-earl-thermal-printer</name>
|
|
4
|
+
<comment>Project react-native-earl-thermal-printer created by Buildship.</comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
</buildSpec>
|
|
14
|
+
<natures>
|
|
15
|
+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
16
|
+
</natures>
|
|
17
|
+
<filteredResources>
|
|
18
|
+
<filter>
|
|
19
|
+
<id>1771390919502</id>
|
|
20
|
+
<name></name>
|
|
21
|
+
<type>30</type>
|
|
22
|
+
<matcher>
|
|
23
|
+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
24
|
+
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
25
|
+
</matcher>
|
|
26
|
+
</filter>
|
|
27
|
+
</filteredResources>
|
|
28
|
+
</projectDescription>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
i/classes_global-synthetics
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
o/classes
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
i/classes_dex
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
o/classes
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
#Wed Feb 18
|
|
1
|
+
#Wed Feb 18 12:50:08 PST 2026
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="
|
|
2
|
+
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\res"><file path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\res\values\strings.xml" qualifiers=""><string name="app_name">RNPrinter</string></file></source></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated" generated-set="generated$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\build\generated\res\resValues\debug"/></dataSet><mergedItems/></merger>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="
|
|
2
|
+
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\debug\shaders"/></dataSet></merger>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="
|
|
2
|
+
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\assets"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\debug\assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\build\intermediates\shader_assets\debug\out"/></dataSet></merger>
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
5 <uses-sdk android:minSdkVersion="21" />
|
|
6
6
|
6
|
|
7
7
|
7 <uses-permission android:name="android.permission.INTERNET" />
|
|
8
|
-
7-->
|
|
9
|
-
7-->
|
|
8
|
+
7-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:4:5-67
|
|
9
|
+
7-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:4:22-64
|
|
10
10
|
8 <uses-permission android:name="android.permission.BLUETOOTH" />
|
|
11
|
-
8-->
|
|
12
|
-
8-->
|
|
11
|
+
8-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:5:5-68
|
|
12
|
+
8-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:5:22-65
|
|
13
13
|
9 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
|
14
|
-
9-->
|
|
15
|
-
9-->
|
|
14
|
+
9-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:6:5-74
|
|
15
|
+
9-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:6:22-71
|
|
16
16
|
10 <uses-permission android:name="android.hardware.usb.UsbAccessory" />
|
|
17
|
-
10-->
|
|
18
|
-
10-->
|
|
17
|
+
10-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:7:5-73
|
|
18
|
+
10-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:7:22-70
|
|
19
19
|
11 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
|
20
|
-
11-->
|
|
21
|
-
11-->
|
|
20
|
+
11-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:8:5-76
|
|
21
|
+
11-->C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:8:22-73
|
|
22
22
|
12
|
|
23
23
|
13</manifest>
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
-- Merging decision tree log ---
|
|
2
2
|
manifest
|
|
3
|
-
ADDED from
|
|
4
|
-
INJECTED from
|
|
3
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:1:1-10:12
|
|
4
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:1:1-10:12
|
|
5
5
|
package
|
|
6
|
-
ADDED from
|
|
7
|
-
INJECTED from
|
|
6
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:2:5-38
|
|
7
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml
|
|
8
8
|
xmlns:android
|
|
9
|
-
ADDED from
|
|
9
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:1:11-69
|
|
10
10
|
uses-permission#android.permission.INTERNET
|
|
11
|
-
ADDED from
|
|
11
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:4:5-67
|
|
12
12
|
android:name
|
|
13
|
-
ADDED from
|
|
13
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:4:22-64
|
|
14
14
|
uses-permission#android.permission.BLUETOOTH
|
|
15
|
-
ADDED from
|
|
15
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:5:5-68
|
|
16
16
|
android:name
|
|
17
|
-
ADDED from
|
|
17
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:5:22-65
|
|
18
18
|
uses-permission#android.permission.BLUETOOTH_ADMIN
|
|
19
|
-
ADDED from
|
|
19
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:6:5-74
|
|
20
20
|
android:name
|
|
21
|
-
ADDED from
|
|
21
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:6:22-71
|
|
22
22
|
uses-permission#android.hardware.usb.UsbAccessory
|
|
23
|
-
ADDED from
|
|
23
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:7:5-73
|
|
24
24
|
android:name
|
|
25
|
-
ADDED from
|
|
25
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:7:22-70
|
|
26
26
|
uses-permission#android.permission.ACCESS_WIFI_STATE
|
|
27
|
-
ADDED from
|
|
27
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:8:5-76
|
|
28
28
|
android:name
|
|
29
|
-
ADDED from
|
|
29
|
+
ADDED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml:8:22-73
|
|
30
30
|
uses-sdk
|
|
31
|
-
INJECTED from
|
|
32
|
-
INJECTED from
|
|
33
|
-
INJECTED from
|
|
31
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml reason: use-sdk injection requested
|
|
32
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml
|
|
33
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml
|
|
34
34
|
android:targetSdkVersion
|
|
35
|
-
INJECTED from
|
|
35
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml
|
|
36
36
|
android:minSdkVersion
|
|
37
|
-
INJECTED from
|
|
37
|
+
INJECTED from C:\Users\earlo\Desktop\react-native-thermal-receipt-printer\example\node_modules\react-native-earl-thermal-printer\android\src\main\AndroidManifest.xml
|
|
@@ -65,14 +65,14 @@ public class RNBLEPrinterModule extends NativeBLEPrinterSpec implements RNPrinte
|
|
|
65
65
|
|
|
66
66
|
@Override
|
|
67
67
|
@ReactMethod
|
|
68
|
-
public void printImageData(String imageUrl, Promise promise) {
|
|
69
|
-
adapter.printImageData(imageUrl, promise);
|
|
68
|
+
public void printImageData(String imageUrl, double imageWidth, Promise promise) {
|
|
69
|
+
adapter.printImageData(imageUrl, imageWidth, promise);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
@Override
|
|
73
73
|
@ReactMethod
|
|
74
|
-
public void printQrCode(String qrCode, Promise promise) {
|
|
75
|
-
adapter.printQrCode(qrCode, promise);
|
|
74
|
+
public void printQrCode(String qrCode, double qrSize, Promise promise) {
|
|
75
|
+
adapter.printQrCode(qrCode, qrSize, promise);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
@Override
|
|
@@ -71,14 +71,14 @@ public class RNNetPrinterModule extends NativeNetPrinterSpec implements RNPrinte
|
|
|
71
71
|
|
|
72
72
|
@Override
|
|
73
73
|
@ReactMethod
|
|
74
|
-
public void printImageData(String imageUrl, Promise promise) {
|
|
75
|
-
adapter.printImageData(imageUrl, promise);
|
|
74
|
+
public void printImageData(String imageUrl, double imageWidth, Promise promise) {
|
|
75
|
+
adapter.printImageData(imageUrl, imageWidth, promise);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
@Override
|
|
79
79
|
@ReactMethod
|
|
80
|
-
public void printQrCode(String qrCode, Promise promise) {
|
|
81
|
-
adapter.printQrCode(qrCode, promise);
|
|
80
|
+
public void printQrCode(String qrCode, double qrSize, Promise promise) {
|
|
81
|
+
adapter.printQrCode(qrCode, qrSize, promise);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
@Override
|
|
@@ -17,8 +17,8 @@ public interface RNPrinterModule {
|
|
|
17
17
|
|
|
18
18
|
void printRawData(String base64Data, Promise promise);
|
|
19
19
|
|
|
20
|
-
void printImageData(String imageUrl, Promise promise);
|
|
20
|
+
void printImageData(String imageUrl, double imageWidth, Promise promise);
|
|
21
21
|
|
|
22
|
-
void printQrCode(String qrCode, Promise promise);
|
|
22
|
+
void printQrCode(String qrCode, double qrSize, Promise promise);
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -67,13 +67,13 @@ public class RNUSBPrinterModule extends NativeUSBPrinterSpec implements RNPrinte
|
|
|
67
67
|
|
|
68
68
|
@Override
|
|
69
69
|
@ReactMethod
|
|
70
|
-
public void printImageData(String imageUrl, Promise promise) {
|
|
71
|
-
adapter.printImageData(imageUrl, promise);
|
|
70
|
+
public void printImageData(String imageUrl, double imageWidth, Promise promise) {
|
|
71
|
+
adapter.printImageData(imageUrl, imageWidth, promise);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
@Override
|
|
75
75
|
@ReactMethod
|
|
76
|
-
public void printQrCode(String qrCode, Promise promise) {
|
|
77
|
-
adapter.printQrCode(qrCode, promise);
|
|
76
|
+
public void printQrCode(String qrCode, double qrSize, Promise promise) {
|
|
77
|
+
adapter.printQrCode(qrCode, qrSize, promise);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -210,7 +210,7 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
@Override
|
|
213
|
-
public void printImageData(String imageUrl, Promise promise) {
|
|
213
|
+
public void printImageData(String imageUrl, double imageWidth, Promise promise) {
|
|
214
214
|
final Bitmap bitmapImage = getBitmapFromURL(imageUrl);
|
|
215
215
|
|
|
216
216
|
if (bitmapImage == null) {
|
|
@@ -223,9 +223,10 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
final BluetoothSocket socket = this.mBluetoothSocket;
|
|
226
|
+
final int maxSize = imageWidth > 0 ? (int) imageWidth : 200;
|
|
226
227
|
|
|
227
228
|
try {
|
|
228
|
-
int[][] pixels = getPixelsSlow(bitmapImage);
|
|
229
|
+
int[][] pixels = getPixelsSlow(bitmapImage, maxSize);
|
|
229
230
|
OutputStream printerOutputStream = socket.getOutputStream();
|
|
230
231
|
|
|
231
232
|
printerOutputStream.write(SET_LINE_SPACE_24);
|
|
@@ -252,8 +253,9 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
@Override
|
|
255
|
-
public void printQrCode(String qrCode, Promise promise) {
|
|
256
|
-
final
|
|
256
|
+
public void printQrCode(String qrCode, double qrSize, Promise promise) {
|
|
257
|
+
final int size = qrSize > 0 ? (int) qrSize : 250;
|
|
258
|
+
final Bitmap bitmapImage = TextToQrImageEncode(qrCode, size);
|
|
257
259
|
|
|
258
260
|
if (bitmapImage == null) {
|
|
259
261
|
promise.reject("ERR_QR", "QR code generation failed");
|
|
@@ -267,7 +269,7 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
267
269
|
final BluetoothSocket socket = this.mBluetoothSocket;
|
|
268
270
|
|
|
269
271
|
try {
|
|
270
|
-
int[][] pixels = getPixelsSlow(bitmapImage);
|
|
272
|
+
int[][] pixels = getPixelsSlow(bitmapImage, size);
|
|
271
273
|
OutputStream printerOutputStream = socket.getOutputStream();
|
|
272
274
|
|
|
273
275
|
printerOutputStream.write(SET_LINE_SPACE_24);
|
|
@@ -293,14 +295,14 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
|
|
296
|
-
private Bitmap TextToQrImageEncode(String Value) {
|
|
298
|
+
private Bitmap TextToQrImageEncode(String Value, int size) {
|
|
297
299
|
com.google.zxing.Writer writer = new QRCodeWriter();
|
|
298
300
|
BitMatrix bitMatrix = null;
|
|
299
301
|
try {
|
|
300
|
-
bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE,
|
|
302
|
+
bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE, size, size,
|
|
301
303
|
ImmutableMap.of(EncodeHintType.MARGIN, 1));
|
|
302
|
-
int width =
|
|
303
|
-
int height =
|
|
304
|
+
int width = size;
|
|
305
|
+
int height = size;
|
|
304
306
|
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
|
305
307
|
|
|
306
308
|
for (int i = 0; i < width; i++) {
|
|
@@ -314,8 +316,8 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
318
|
|
|
317
|
-
public static int[][] getPixelsSlow(Bitmap image2) {
|
|
318
|
-
Bitmap image = resizeTheImageForPrinting(image2);
|
|
319
|
+
public static int[][] getPixelsSlow(Bitmap image2, int maxSize) {
|
|
320
|
+
Bitmap image = resizeTheImageForPrinting(image2, maxSize);
|
|
319
321
|
int width = image.getWidth();
|
|
320
322
|
int height = image.getHeight();
|
|
321
323
|
int[][] result = new int[height][width];
|
|
@@ -360,15 +362,15 @@ public class BLEPrinterAdapter implements PrinterAdapter {
|
|
|
360
362
|
return luminance < threshold;
|
|
361
363
|
}
|
|
362
364
|
|
|
363
|
-
public static Bitmap resizeTheImageForPrinting(Bitmap image) {
|
|
365
|
+
public static Bitmap resizeTheImageForPrinting(Bitmap image, int maxSize) {
|
|
364
366
|
int width = image.getWidth();
|
|
365
367
|
int height = image.getHeight();
|
|
366
|
-
if (width >
|
|
368
|
+
if (width > maxSize || height > maxSize) {
|
|
367
369
|
if (width > height) {
|
|
368
|
-
float decreaseSizeBy = (
|
|
370
|
+
float decreaseSizeBy = ((float) maxSize / width);
|
|
369
371
|
return getBitmapResized(image, decreaseSizeBy);
|
|
370
372
|
} else {
|
|
371
|
-
float decreaseSizeBy = (
|
|
373
|
+
float decreaseSizeBy = ((float) maxSize / height);
|
|
372
374
|
return getBitmapResized(image, decreaseSizeBy);
|
|
373
375
|
}
|
|
374
376
|
}
|
|
@@ -250,7 +250,7 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
@Override
|
|
253
|
-
public void printImageData(final String imageUrl, Promise promise) {
|
|
253
|
+
public void printImageData(final String imageUrl, double imageWidth, Promise promise) {
|
|
254
254
|
final Bitmap bitmapImage = getBitmapFromURL(imageUrl);
|
|
255
255
|
|
|
256
256
|
if (bitmapImage == null) {
|
|
@@ -264,9 +264,10 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
final Socket socket = this.mSocket;
|
|
267
|
+
final int maxSize = imageWidth > 0 ? (int) imageWidth : 200;
|
|
267
268
|
|
|
268
269
|
try {
|
|
269
|
-
int[][] pixels = getPixelsSlow(bitmapImage);
|
|
270
|
+
int[][] pixels = getPixelsSlow(bitmapImage, maxSize);
|
|
270
271
|
OutputStream printerOutputStream = socket.getOutputStream();
|
|
271
272
|
|
|
272
273
|
printerOutputStream.write(SET_LINE_SPACE_24);
|
|
@@ -293,8 +294,9 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
293
294
|
}
|
|
294
295
|
|
|
295
296
|
@Override
|
|
296
|
-
public void printQrCode(String qrCode, Promise promise) {
|
|
297
|
-
final
|
|
297
|
+
public void printQrCode(String qrCode, double qrSize, Promise promise) {
|
|
298
|
+
final int size = qrSize > 0 ? (int) qrSize : 250;
|
|
299
|
+
final Bitmap bitmapImage = TextToQrImageEncode(qrCode, size);
|
|
298
300
|
|
|
299
301
|
if (bitmapImage == null) {
|
|
300
302
|
promise.reject("ERR_QR", "QR code generation failed");
|
|
@@ -309,7 +311,7 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
309
311
|
final Socket socket = this.mSocket;
|
|
310
312
|
|
|
311
313
|
try {
|
|
312
|
-
int[][] pixels = getPixelsSlow(bitmapImage);
|
|
314
|
+
int[][] pixels = getPixelsSlow(bitmapImage, size);
|
|
313
315
|
OutputStream printerOutputStream = socket.getOutputStream();
|
|
314
316
|
|
|
315
317
|
printerOutputStream.write(SET_LINE_SPACE_24);
|
|
@@ -335,14 +337,14 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
335
337
|
}
|
|
336
338
|
}
|
|
337
339
|
|
|
338
|
-
private Bitmap TextToQrImageEncode(String Value) {
|
|
340
|
+
private Bitmap TextToQrImageEncode(String Value, int size) {
|
|
339
341
|
com.google.zxing.Writer writer = new QRCodeWriter();
|
|
340
342
|
BitMatrix bitMatrix = null;
|
|
341
343
|
try {
|
|
342
|
-
bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE,
|
|
344
|
+
bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE, size, size,
|
|
343
345
|
ImmutableMap.of(EncodeHintType.MARGIN, 1));
|
|
344
|
-
int width =
|
|
345
|
-
int height =
|
|
346
|
+
int width = size;
|
|
347
|
+
int height = size;
|
|
346
348
|
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
|
347
349
|
|
|
348
350
|
for (int i = 0; i < width; i++) {
|
|
@@ -356,8 +358,8 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
356
358
|
}
|
|
357
359
|
}
|
|
358
360
|
|
|
359
|
-
public static int[][] getPixelsSlow(Bitmap image2) {
|
|
360
|
-
Bitmap image = resizeTheImageForPrinting(image2);
|
|
361
|
+
public static int[][] getPixelsSlow(Bitmap image2, int maxSize) {
|
|
362
|
+
Bitmap image = resizeTheImageForPrinting(image2, maxSize);
|
|
361
363
|
int width = image.getWidth();
|
|
362
364
|
int height = image.getHeight();
|
|
363
365
|
int[][] result = new int[height][width];
|
|
@@ -402,15 +404,15 @@ public class NetPrinterAdapter implements PrinterAdapter {
|
|
|
402
404
|
return luminance < threshold;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
|
-
public static Bitmap resizeTheImageForPrinting(Bitmap image) {
|
|
407
|
+
public static Bitmap resizeTheImageForPrinting(Bitmap image, int maxSize) {
|
|
406
408
|
int width = image.getWidth();
|
|
407
409
|
int height = image.getHeight();
|
|
408
|
-
if (width >
|
|
410
|
+
if (width > maxSize || height > maxSize) {
|
|
409
411
|
if (width > height) {
|
|
410
|
-
float decreaseSizeBy = (
|
|
412
|
+
float decreaseSizeBy = ((float) maxSize / width);
|
|
411
413
|
return getBitmapResized(image, decreaseSizeBy);
|
|
412
414
|
} else {
|
|
413
|
-
float decreaseSizeBy = (
|
|
415
|
+
float decreaseSizeBy = ((float) maxSize / height);
|
|
414
416
|
return getBitmapResized(image, decreaseSizeBy);
|
|
415
417
|
}
|
|
416
418
|
}
|
|
@@ -23,7 +23,7 @@ public interface PrinterAdapter {
|
|
|
23
23
|
|
|
24
24
|
void printRawData(String rawBase64Data, Promise promise);
|
|
25
25
|
|
|
26
|
-
void printImageData(String imageUrl, Promise promise);
|
|
26
|
+
void printImageData(String imageUrl, double imageWidth, Promise promise);
|
|
27
27
|
|
|
28
|
-
void printQrCode(String qrCode, Promise promise);
|
|
28
|
+
void printQrCode(String qrCode, double qrSize, Promise promise);
|
|
29
29
|
}
|
|
@@ -275,7 +275,7 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
@Override
|
|
278
|
-
public void printImageData(final String imageUrl, Promise promise) {
|
|
278
|
+
public void printImageData(final String imageUrl, double imageWidth, Promise promise) {
|
|
279
279
|
final Bitmap bitmapImage = getBitmapFromURL(imageUrl);
|
|
280
280
|
|
|
281
281
|
if (bitmapImage == null) {
|
|
@@ -288,7 +288,8 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
288
288
|
if (isConnected) {
|
|
289
289
|
Log.v(LOG_TAG, "Connected to device");
|
|
290
290
|
try {
|
|
291
|
-
int
|
|
291
|
+
final int maxSize = imageWidth > 0 ? (int) imageWidth : 200;
|
|
292
|
+
int[][] pixels = getPixelsSlow(bitmapImage, maxSize);
|
|
292
293
|
|
|
293
294
|
mUsbDeviceConnection.bulkTransfer(mEndPoint, SET_LINE_SPACE_24, SET_LINE_SPACE_24.length, 100000);
|
|
294
295
|
mUsbDeviceConnection.bulkTransfer(mEndPoint, CENTER_ALIGN, CENTER_ALIGN.length, 100000);
|
|
@@ -322,14 +323,14 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
|
|
325
|
-
private Bitmap TextToQrImageEncode(String Value) {
|
|
326
|
+
private Bitmap TextToQrImageEncode(String Value, int size) {
|
|
326
327
|
com.google.zxing.Writer writer = new QRCodeWriter();
|
|
327
328
|
BitMatrix bitMatrix = null;
|
|
328
329
|
try {
|
|
329
|
-
bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE,
|
|
330
|
+
bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE, size, size,
|
|
330
331
|
ImmutableMap.of(EncodeHintType.MARGIN, 1));
|
|
331
|
-
int width =
|
|
332
|
-
int height =
|
|
332
|
+
int width = size;
|
|
333
|
+
int height = size;
|
|
333
334
|
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
|
334
335
|
|
|
335
336
|
for (int i = 0; i < width; i++) {
|
|
@@ -344,8 +345,9 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
@Override
|
|
347
|
-
public void printQrCode(String qrCode, Promise promise) {
|
|
348
|
-
final
|
|
348
|
+
public void printQrCode(String qrCode, double qrSize, Promise promise) {
|
|
349
|
+
final int size = qrSize > 0 ? (int) qrSize : 250;
|
|
350
|
+
final Bitmap bitmapImage = TextToQrImageEncode(qrCode, size);
|
|
349
351
|
|
|
350
352
|
if (bitmapImage == null) {
|
|
351
353
|
promise.reject("ERR_QR", "QR code generation failed");
|
|
@@ -357,7 +359,7 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
357
359
|
if (isConnected) {
|
|
358
360
|
Log.v(LOG_TAG, "Connected to device");
|
|
359
361
|
try {
|
|
360
|
-
int[][] pixels = getPixelsSlow(bitmapImage);
|
|
362
|
+
int[][] pixels = getPixelsSlow(bitmapImage, size);
|
|
361
363
|
|
|
362
364
|
mUsbDeviceConnection.bulkTransfer(mEndPoint, SET_LINE_SPACE_24, SET_LINE_SPACE_24.length, 100000);
|
|
363
365
|
mUsbDeviceConnection.bulkTransfer(mEndPoint, CENTER_ALIGN, CENTER_ALIGN.length, 100000);
|
|
@@ -391,8 +393,8 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
395
|
|
|
394
|
-
public static int[][] getPixelsSlow(Bitmap image2) {
|
|
395
|
-
Bitmap image = resizeTheImageForPrinting(image2);
|
|
396
|
+
public static int[][] getPixelsSlow(Bitmap image2, int maxSize) {
|
|
397
|
+
Bitmap image = resizeTheImageForPrinting(image2, maxSize);
|
|
396
398
|
int width = image.getWidth();
|
|
397
399
|
int height = image.getHeight();
|
|
398
400
|
int[][] result = new int[height][width];
|
|
@@ -437,15 +439,15 @@ public class USBPrinterAdapter implements PrinterAdapter {
|
|
|
437
439
|
return luminance < threshold;
|
|
438
440
|
}
|
|
439
441
|
|
|
440
|
-
public static Bitmap resizeTheImageForPrinting(Bitmap image) {
|
|
442
|
+
public static Bitmap resizeTheImageForPrinting(Bitmap image, int maxSize) {
|
|
441
443
|
int width = image.getWidth();
|
|
442
444
|
int height = image.getHeight();
|
|
443
|
-
if (width >
|
|
445
|
+
if (width > maxSize || height > maxSize) {
|
|
444
446
|
if (width > height) {
|
|
445
|
-
float decreaseSizeBy = (
|
|
447
|
+
float decreaseSizeBy = ((float) maxSize / width);
|
|
446
448
|
return getBitmapResized(image, decreaseSizeBy);
|
|
447
449
|
} else {
|
|
448
|
-
float decreaseSizeBy = (
|
|
450
|
+
float decreaseSizeBy = ((float) maxSize / height);
|
|
449
451
|
return getBitmapResized(image, decreaseSizeBy);
|
|
450
452
|
}
|
|
451
453
|
}
|
|
@@ -5,8 +5,8 @@ export interface Spec extends TurboModule {
|
|
|
5
5
|
connectPrinter(innerAddress: string): Promise<Object>;
|
|
6
6
|
closeConn(): void;
|
|
7
7
|
printRawData(base64Data: string): Promise<void>;
|
|
8
|
-
printImageData(imageUrl: string): Promise<void>;
|
|
9
|
-
printQrCode(qrCode: string): Promise<void>;
|
|
8
|
+
printImageData(imageUrl: string, imageWidth: number): Promise<void>;
|
|
9
|
+
printQrCode(qrCode: string, qrSize: number): Promise<void>;
|
|
10
10
|
addListener(eventName: string): void;
|
|
11
11
|
removeListeners(count: number): void;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeBLEPrinter.d.ts","sourceRoot":"","sources":["../src/NativeBLEPrinter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACxC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,SAAS,IAAI,IAAI,CAAC;IAClB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeBLEPrinter.d.ts","sourceRoot":"","sources":["../src/NativeBLEPrinter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACxC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,SAAS,IAAI,IAAI,CAAC;IAClB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;;AAED,wBAAsE"}
|
|
@@ -5,8 +5,8 @@ export interface Spec extends TurboModule {
|
|
|
5
5
|
connectPrinter(host: string, port: number): Promise<Object>;
|
|
6
6
|
closeConn(): void;
|
|
7
7
|
printRawData(base64Data: string): Promise<void>;
|
|
8
|
-
printImageData(imageUrl: string): Promise<void>;
|
|
9
|
-
printQrCode(qrCode: string): Promise<void>;
|
|
8
|
+
printImageData(imageUrl: string, imageWidth: number): Promise<void>;
|
|
9
|
+
printQrCode(qrCode: string, qrSize: number): Promise<void>;
|
|
10
10
|
addListener(eventName: string): void;
|
|
11
11
|
removeListeners(count: number): void;
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeNetPrinter.d.ts","sourceRoot":"","sources":["../src/Native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ACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;;AAED,wBAAsE"}
|
|
@@ -5,8 +5,8 @@ export interface Spec extends TurboModule {
|
|
|
5
5
|
connectPrinter(vendorId: number, productId: number): Promise<Object>;
|
|
6
6
|
closeConn(): void;
|
|
7
7
|
printRawData(base64Data: string): Promise<void>;
|
|
8
|
-
printImageData(imageUrl: string): Promise<void>;
|
|
9
|
-
printQrCode(qrCode: string): Promise<void>;
|
|
8
|
+
printImageData(imageUrl: string, imageWidth: number): Promise<void>;
|
|
9
|
+
printQrCode(qrCode: string, qrSize: number): Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
declare const _default: Spec;
|
|
12
12
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeUSBPrinter.d.ts","sourceRoot":"","sources":["../src/NativeUSBPrinter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACxC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrE,SAAS,IAAI,IAAI,CAAC;IAClB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeUSBPrinter.d.ts","sourceRoot":"","sources":["../src/NativeUSBPrinter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACxC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrE,SAAS,IAAI,IAAI,CAAC;IAClB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;;AAED,wBAAsE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare const USBPrinter: {
|
|
|
27
27
|
closeConn: () => void;
|
|
28
28
|
printText: (text: string, opts?: PrinterOptions) => Promise<void>;
|
|
29
29
|
printBill: (text: string, opts?: PrinterOptions) => Promise<void>;
|
|
30
|
-
printImage: (imageUrl: string) => Promise<void>;
|
|
31
|
-
printQrCode: (qrCode: string) => Promise<void>;
|
|
30
|
+
printImage: (imageUrl: string, imageWidth?: number) => Promise<void>;
|
|
31
|
+
printQrCode: (qrCode: string, qrSize?: number) => Promise<void>;
|
|
32
32
|
};
|
|
33
33
|
export declare const BLEPrinter: {
|
|
34
34
|
init: () => Promise<string>;
|
|
@@ -37,8 +37,8 @@ export declare const BLEPrinter: {
|
|
|
37
37
|
closeConn: () => void;
|
|
38
38
|
printText: (text: string, opts?: PrinterOptions) => Promise<void>;
|
|
39
39
|
printBill: (text: string, opts?: PrinterOptions) => Promise<void>;
|
|
40
|
-
printImage: (imageUrl: string) => Promise<void>;
|
|
41
|
-
printQrCode: (qrCode: string) => Promise<void>;
|
|
40
|
+
printImage: (imageUrl: string, imageWidth?: number) => Promise<void>;
|
|
41
|
+
printQrCode: (qrCode: string, qrSize?: number) => Promise<void>;
|
|
42
42
|
};
|
|
43
43
|
export declare const NetPrinter: {
|
|
44
44
|
init: () => Promise<string>;
|
|
@@ -47,8 +47,8 @@ export declare const NetPrinter: {
|
|
|
47
47
|
closeConn: () => void;
|
|
48
48
|
printText: (text: string, opts?: PrinterOptions) => Promise<void>;
|
|
49
49
|
printBill: (text: string, opts?: PrinterOptions) => Promise<void>;
|
|
50
|
-
printImage: (imageUrl: string) => Promise<void>;
|
|
51
|
-
printQrCode: (qrCode: string) => Promise<void>;
|
|
50
|
+
printImage: (imageUrl: string, imageWidth?: number) => Promise<void>;
|
|
51
|
+
printQrCode: (qrCode: string, qrSize?: number) => Promise<void>;
|
|
52
52
|
};
|
|
53
53
|
export declare const NetPrinterEventEmitter: NativeEventEmitter;
|
|
54
54
|
export declare enum RN_THERMAL_RECEIPT_PRINTER_EVENTS {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AASlD,MAAM,WAAW,cAAc;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,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USBPrinterModule.printRawData(textTo64Buffer(text, opts)),
|
|
24
24
|
printBill: (text, opts = {}) => NativeUSBPrinterModule.printRawData(billTo64Buffer(text, opts)),
|
|
25
|
-
printImage: (imageUrl) => NativeUSBPrinterModule.printImageData(imageUrl),
|
|
26
|
-
printQrCode: (qrCode) => NativeUSBPrinterModule.printQrCode(qrCode),
|
|
25
|
+
printImage: (imageUrl, imageWidth = 200) => NativeUSBPrinterModule.printImageData(imageUrl, imageWidth),
|
|
26
|
+
printQrCode: (qrCode, qrSize = 250) => NativeUSBPrinterModule.printQrCode(qrCode, qrSize),
|
|
27
27
|
};
|
|
28
28
|
// ── BLE Printer ─────────────────────────────────────────────────────────────
|
|
29
29
|
export const BLEPrinter = {
|
|
@@ -33,8 +33,8 @@ export const BLEPrinter = {
|
|
|
33
33
|
closeConn: () => NativeBLEPrinterModule.closeConn(),
|
|
34
34
|
printText: (text, opts = {}) => NativeBLEPrinterModule.printRawData(textTo64Buffer(text, opts)),
|
|
35
35
|
printBill: (text, opts = {}) => NativeBLEPrinterModule.printRawData(billTo64Buffer(text, opts)),
|
|
36
|
-
printImage: (imageUrl) => NativeBLEPrinterModule.printImageData(imageUrl),
|
|
37
|
-
printQrCode: (qrCode) => NativeBLEPrinterModule.printQrCode(qrCode),
|
|
36
|
+
printImage: (imageUrl, imageWidth = 200) => NativeBLEPrinterModule.printImageData(imageUrl, imageWidth),
|
|
37
|
+
printQrCode: (qrCode, qrSize = 250) => NativeBLEPrinterModule.printQrCode(qrCode, qrSize),
|
|
38
38
|
};
|
|
39
39
|
// ── Net Printer ─────────────────────────────────────────────────────────────
|
|
40
40
|
export const NetPrinter = {
|
|
@@ -44,8 +44,8 @@ export const NetPrinter = {
|
|
|
44
44
|
closeConn: () => NativeNetPrinterModule.closeConn(),
|
|
45
45
|
printText: (text, opts = {}) => NativeNetPrinterModule.printRawData(textTo64Buffer(text, opts)),
|
|
46
46
|
printBill: (text, opts = {}) => NativeNetPrinterModule.printRawData(billTo64Buffer(text, opts)),
|
|
47
|
-
printImage: (imageUrl) => NativeNetPrinterModule.printImageData(imageUrl),
|
|
48
|
-
printQrCode: (qrCode) => NativeNetPrinterModule.printQrCode(qrCode),
|
|
47
|
+
printImage: (imageUrl, imageWidth = 200) => NativeNetPrinterModule.printImageData(imageUrl, imageWidth),
|
|
48
|
+
printQrCode: (qrCode, qrSize = 250) => NativeNetPrinterModule.printQrCode(qrCode, qrSize),
|
|
49
49
|
};
|
|
50
50
|
// ── Events ──────────────────────────────────────────────────────────────────
|
|
51
51
|
export const NetPrinterEventEmitter = new NativeEventEmitter(NativeNetPrinterModule);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,sBAAsB,MAAM,oBAAoB,CAAC;AACxD,OAAO,sBAAsB,MAAM,oBAAoB,CAAC;AACxD,OAAO,sBAAsB,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AA6B/C,+EAA+E;AAE/E,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,IAAoB,EAAU,EAAE;IACrE,MAAM,OAAO,mBACZ,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,MAAM,IACb,IAAI,CACP,CAAC;IACF,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,IAAoB,EAAU,EAAE;IACrE,MAAM,OAAO,mBACZ,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,EACT,WAAW,EAAE,IAAI,EACj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PORT_METHOD(printImageData:(NSString *)imageUrl
|
|
134
|
+
imageWidth:(double)imageWidth
|
|
134
135
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
135
136
|
reject:(RCTPromiseRejectBlock)reject)
|
|
136
137
|
{
|
|
@@ -139,11 +140,12 @@ RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
|
139
140
|
reject(@"ERR_NO_CONN", @"Not connected to a printer", nil);
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
143
|
+
CGFloat width = imageWidth > 0 ? (CGFloat)imageWidth : 150;
|
|
142
144
|
NSURL *url = [NSURL URLWithString:imageUrl];
|
|
143
145
|
NSData *imageData = [NSData dataWithContentsOfURL:url];
|
|
144
146
|
if (imageData != nil) {
|
|
145
147
|
UIImage *image = [UIImage imageWithData:imageData];
|
|
146
|
-
UIImage *printImage = [self getPrintImage:image width:
|
|
148
|
+
UIImage *printImage = [self getPrintImage:image width:width paddingX:250];
|
|
147
149
|
[[PrinterSDK defaultPrinterSDK] setPrintWidth:576];
|
|
148
150
|
[[PrinterSDK defaultPrinterSDK] printImage:printImage];
|
|
149
151
|
resolve(nil);
|
|
@@ -156,6 +158,7 @@ RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
RCT_EXPORT_METHOD(printQrCode:(NSString *)qrCode
|
|
161
|
+
qrSize:(double)qrSize
|
|
159
162
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
160
163
|
reject:(RCTPromiseRejectBlock)reject)
|
|
161
164
|
{
|
package/ios/RNNetPrinter.mm
CHANGED
|
@@ -186,6 +186,7 @@ RCT_EXPORT_METHOD(printRawData:(NSString *)base64Data
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
189
|
+
imageWidth:(double)imageWidth
|
|
189
190
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
190
191
|
reject:(RCTPromiseRejectBlock)reject)
|
|
191
192
|
{
|
|
@@ -194,11 +195,12 @@ RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
|
194
195
|
reject(@"ERR_NO_CONN", @"Not connected to a printer", nil);
|
|
195
196
|
return;
|
|
196
197
|
}
|
|
198
|
+
CGFloat width = imageWidth > 0 ? (CGFloat)imageWidth : 150;
|
|
197
199
|
NSURL *url = [NSURL URLWithString:imageUrl];
|
|
198
200
|
NSData *imageData = [NSData dataWithContentsOfURL:url];
|
|
199
201
|
if (imageData != nil) {
|
|
200
202
|
UIImage *image = [UIImage imageWithData:imageData];
|
|
201
|
-
UIImage *printImage = [self getPrintImage:image width:
|
|
203
|
+
UIImage *printImage = [self getPrintImage:image width:width paddingX:250];
|
|
202
204
|
[[PrinterSDK defaultPrinterSDK] setPrintWidth:576];
|
|
203
205
|
[[PrinterSDK defaultPrinterSDK] printImage:printImage];
|
|
204
206
|
resolve(nil);
|
|
@@ -211,6 +213,7 @@ RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
RCT_EXPORT_METHOD(printQrCode:(NSString *)qrCode
|
|
216
|
+
qrSize:(double)qrSize
|
|
214
217
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
215
218
|
reject:(RCTPromiseRejectBlock)reject)
|
|
216
219
|
{
|
package/ios/RNUSBPrinter.mm
CHANGED
|
@@ -51,6 +51,7 @@ RCT_EXPORT_METHOD(printRawData:(NSString *)base64Data
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
54
|
+
imageWidth:(double)imageWidth
|
|
54
55
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
55
56
|
reject:(RCTPromiseRejectBlock)reject)
|
|
56
57
|
{
|
|
@@ -58,6 +59,7 @@ RCT_EXPORT_METHOD(printImageData:(NSString *)imageUrl
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
RCT_EXPORT_METHOD(printQrCode:(NSString *)qrCode
|
|
62
|
+
qrSize:(double)qrSize
|
|
61
63
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
62
64
|
reject:(RCTPromiseRejectBlock)reject)
|
|
63
65
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-earl-thermal-printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A modern, high-performance thermal printer library for React Native. Built with the New Architecture (TurboModules) for synchronous communication, zero legacy bridge overhead, and Android 12+ Bluetooth compliance.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/NativeBLEPrinter.ts
CHANGED
|
@@ -7,8 +7,8 @@ export interface Spec extends TurboModule {
|
|
|
7
7
|
connectPrinter(innerAddress: string): Promise<Object>;
|
|
8
8
|
closeConn(): void;
|
|
9
9
|
printRawData(base64Data: string): Promise<void>;
|
|
10
|
-
printImageData(imageUrl: string): Promise<void>;
|
|
11
|
-
printQrCode(qrCode: string): Promise<void>;
|
|
10
|
+
printImageData(imageUrl: string, imageWidth: number): Promise<void>;
|
|
11
|
+
printQrCode(qrCode: string, qrSize: number): Promise<void>;
|
|
12
12
|
addListener(eventName: string): void;
|
|
13
13
|
removeListeners(count: number): void;
|
|
14
14
|
}
|
package/src/NativeNetPrinter.ts
CHANGED
|
@@ -7,8 +7,8 @@ export interface Spec extends TurboModule {
|
|
|
7
7
|
connectPrinter(host: string, port: number): Promise<Object>;
|
|
8
8
|
closeConn(): void;
|
|
9
9
|
printRawData(base64Data: string): Promise<void>;
|
|
10
|
-
printImageData(imageUrl: string): Promise<void>;
|
|
11
|
-
printQrCode(qrCode: string): Promise<void>;
|
|
10
|
+
printImageData(imageUrl: string, imageWidth: number): Promise<void>;
|
|
11
|
+
printQrCode(qrCode: string, qrSize: number): Promise<void>;
|
|
12
12
|
addListener(eventName: string): void;
|
|
13
13
|
removeListeners(count: number): void;
|
|
14
14
|
}
|
package/src/NativeUSBPrinter.ts
CHANGED
|
@@ -7,8 +7,8 @@ export interface Spec extends TurboModule {
|
|
|
7
7
|
connectPrinter(vendorId: number, productId: number): Promise<Object>;
|
|
8
8
|
closeConn(): void;
|
|
9
9
|
printRawData(base64Data: string): Promise<void>;
|
|
10
|
-
printImageData(imageUrl: string): Promise<void>;
|
|
11
|
-
printQrCode(qrCode: string): Promise<void>;
|
|
10
|
+
printImageData(imageUrl: string, imageWidth: number): Promise<void>;
|
|
11
|
+
printQrCode(qrCode: string, qrSize: number): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export default TurboModuleRegistry.getEnforcing<Spec>("RNUSBPrinter");
|
package/src/index.ts
CHANGED
|
@@ -83,11 +83,11 @@ export const USBPrinter = {
|
|
|
83
83
|
printBill: (text: string, opts: PrinterOptions = {}): Promise<void> =>
|
|
84
84
|
NativeUSBPrinterModule.printRawData(billTo64Buffer(text, opts)),
|
|
85
85
|
|
|
86
|
-
printImage: (imageUrl: string): Promise<void> =>
|
|
87
|
-
NativeUSBPrinterModule.printImageData(imageUrl),
|
|
86
|
+
printImage: (imageUrl: string, imageWidth: number = 200): Promise<void> =>
|
|
87
|
+
NativeUSBPrinterModule.printImageData(imageUrl, imageWidth),
|
|
88
88
|
|
|
89
|
-
printQrCode: (qrCode: string): Promise<void> =>
|
|
90
|
-
NativeUSBPrinterModule.printQrCode(qrCode),
|
|
89
|
+
printQrCode: (qrCode: string, qrSize: number = 250): Promise<void> =>
|
|
90
|
+
NativeUSBPrinterModule.printQrCode(qrCode, qrSize),
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// ── BLE Printer ─────────────────────────────────────────────────────────────
|
|
@@ -111,11 +111,11 @@ export const BLEPrinter = {
|
|
|
111
111
|
printBill: (text: string, opts: PrinterOptions = {}): Promise<void> =>
|
|
112
112
|
NativeBLEPrinterModule.printRawData(billTo64Buffer(text, opts)),
|
|
113
113
|
|
|
114
|
-
printImage: (imageUrl: string): Promise<void> =>
|
|
115
|
-
NativeBLEPrinterModule.printImageData(imageUrl),
|
|
114
|
+
printImage: (imageUrl: string, imageWidth: number = 200): Promise<void> =>
|
|
115
|
+
NativeBLEPrinterModule.printImageData(imageUrl, imageWidth),
|
|
116
116
|
|
|
117
|
-
printQrCode: (qrCode: string): Promise<void> =>
|
|
118
|
-
NativeBLEPrinterModule.printQrCode(qrCode),
|
|
117
|
+
printQrCode: (qrCode: string, qrSize: number = 250): Promise<void> =>
|
|
118
|
+
NativeBLEPrinterModule.printQrCode(qrCode, qrSize),
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// ── Net Printer ─────────────────────────────────────────────────────────────
|
|
@@ -140,11 +140,11 @@ export const NetPrinter = {
|
|
|
140
140
|
printBill: (text: string, opts: PrinterOptions = {}): Promise<void> =>
|
|
141
141
|
NativeNetPrinterModule.printRawData(billTo64Buffer(text, opts)),
|
|
142
142
|
|
|
143
|
-
printImage: (imageUrl: string): Promise<void> =>
|
|
144
|
-
NativeNetPrinterModule.printImageData(imageUrl),
|
|
143
|
+
printImage: (imageUrl: string, imageWidth: number = 200): Promise<void> =>
|
|
144
|
+
NativeNetPrinterModule.printImageData(imageUrl, imageWidth),
|
|
145
145
|
|
|
146
|
-
printQrCode: (qrCode: string): Promise<void> =>
|
|
147
|
-
NativeNetPrinterModule.printQrCode(qrCode),
|
|
146
|
+
printQrCode: (qrCode: string, qrSize: number = 250): Promise<void> =>
|
|
147
|
+
NativeNetPrinterModule.printQrCode(qrCode, qrSize),
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
// ── Events ──────────────────────────────────────────────────────────────────
|