react-native-earl-thermal-printer 1.0.1 → 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/README.md CHANGED
@@ -73,6 +73,8 @@ const devices = await USBPrinter.getDeviceList();
73
73
  await USBPrinter.connectPrinter(devices[0].vendor_id, devices[0].product_id);
74
74
  await USBPrinter.printText("Hello from USB!\n");
75
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);
76
78
  USBPrinter.closeConn();
77
79
  ```
78
80
 
@@ -84,6 +86,8 @@ const devices = await BLEPrinter.getDeviceList();
84
86
  await BLEPrinter.connectPrinter(devices[0].inner_mac_address);
85
87
  await BLEPrinter.printText("Hello from BLE!\n");
86
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);
87
91
  BLEPrinter.closeConn();
88
92
  ```
89
93
 
@@ -102,6 +106,8 @@ const devices = await NetPrinter.getDeviceList();
102
106
  await NetPrinter.connectPrinter("192.168.1.100", 9100);
103
107
  await NetPrinter.printText("Hello from Network!\n");
104
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);
105
111
  NetPrinter.closeConn();
106
112
  ```
107
113
 
@@ -137,13 +143,13 @@ Print a text string using ESC/POS encoding. Supports formatting tags (see below)
137
143
 
138
144
  Same as `printText` but defaults `beep`, `cut`, and `tailingLine` to `true`.
139
145
 
140
- ### `printImage(imageUrl: string): Promise<void>`
146
+ ### `printImage(imageUrl: string, imageWidth?: number): Promise<void>`
141
147
 
142
- 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).
143
149
 
144
- ### `printQrCode(qrCode: string): Promise<void>`
150
+ ### `printQrCode(qrCode: string, qrSize?: number): Promise<void>`
145
151
 
146
- 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`).
147
153
 
148
154
  ### `closeConn(): void`
149
155
 
@@ -351,7 +357,7 @@ export default function ThermalPrinterTest() {
351
357
 
352
358
  try {
353
359
  // To print a QR code:
354
- await BLEPrinter.printQrCode("ZAM-OC-0001");
360
+ await BLEPrinter.printQrCode("ZAM-OC-0001", 100); // qrSize
355
361
  // Print formatted receipt text (beeps + cuts automatically)
356
362
  const bill =
357
363
  "--------------------------------\n" +
@@ -364,8 +370,9 @@ export default function ThermalPrinterTest() {
364
370
 
365
371
  // To print an image from URL:
366
372
  // await BLEPrinter.printImage(
367
- // "https://images.unsplash.com/photo-1771258052747-52e19364185f?q=80&w=765&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
368
- // );
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
+ );
369
376
  } catch (err) {
370
377
  console.warn("Print error:", err);
371
378
  Alert.alert("Print Error", String(err));
package/android/.project CHANGED
@@ -5,11 +5,6 @@
5
5
  <projects>
6
6
  </projects>
7
7
  <buildSpec>
8
- <buildCommand>
9
- <name>org.eclipse.jdt.core.javabuilder</name>
10
- <arguments>
11
- </arguments>
12
- </buildCommand>
13
8
  <buildCommand>
14
9
  <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
10
  <arguments>
@@ -17,7 +12,6 @@
17
12
  </buildCommand>
18
13
  </buildSpec>
19
14
  <natures>
20
- <nature>org.eclipse.jdt.core.javanature</nature>
21
15
  <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
16
  </natures>
23
17
  <filteredResources>
@@ -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 Bitmap bitmapImage = TextToQrImageEncode(qrCode);
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, 250, 250,
302
+ bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE, size, size,
301
303
  ImmutableMap.of(EncodeHintType.MARGIN, 1));
302
- int width = 250;
303
- int height = 250;
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 > 200 || height > 200) {
368
+ if (width > maxSize || height > maxSize) {
367
369
  if (width > height) {
368
- float decreaseSizeBy = (200.0f / width);
370
+ float decreaseSizeBy = ((float) maxSize / width);
369
371
  return getBitmapResized(image, decreaseSizeBy);
370
372
  } else {
371
- float decreaseSizeBy = (200.0f / height);
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 Bitmap bitmapImage = TextToQrImageEncode(qrCode);
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, 250, 250,
344
+ bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE, size, size,
343
345
  ImmutableMap.of(EncodeHintType.MARGIN, 1));
344
- int width = 250;
345
- int height = 250;
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 > 200 || height > 200) {
410
+ if (width > maxSize || height > maxSize) {
409
411
  if (width > height) {
410
- float decreaseSizeBy = (200.0f / width);
412
+ float decreaseSizeBy = ((float) maxSize / width);
411
413
  return getBitmapResized(image, decreaseSizeBy);
412
414
  } else {
413
- float decreaseSizeBy = (200.0f / height);
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[][] pixels = getPixelsSlow(bitmapImage);
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, 250, 250,
330
+ bitMatrix = writer.encode(Value, com.google.zxing.BarcodeFormat.QR_CODE, size, size,
330
331
  ImmutableMap.of(EncodeHintType.MARGIN, 1));
331
- int width = 250;
332
- int height = 250;
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 Bitmap bitmapImage = TextToQrImageEncode(qrCode);
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 > 200 || height > 200) {
445
+ if (width > maxSize || height > maxSize) {
444
446
  if (width > height) {
445
- float decreaseSizeBy = (200.0f / width);
447
+ float decreaseSizeBy = ((float) maxSize / width);
446
448
  return getBitmapResized(image, decreaseSizeBy);
447
449
  } else {
448
- float decreaseSizeBy = (200.0f / height);
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;IAChD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;;AAED,wBAAsE"}
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/NativeNetPrinter.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,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,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;IAChD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;;AAED,wBAAsE"}
1
+ {"version":3,"file":"NativeNetPrinter.d.ts","sourceRoot":"","sources":["../src/NativeNetPrinter.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,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5D,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(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;IAChD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;;AAED,wBAAsE"}
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 {
@@ -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,M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Z,OAAO,CAAC,MAAM,CAAC;yBAEN,OAAO,CAAC,WAAW,EAAE,CAAC;sCAGP,MAAM,KAAG,OAAO,CAAC,WAAW,CAAC;qBAKhD,IAAI;sBAED,MAAM,SAAQ,cAAc,KAAQ,OAAO,CAAC,IAAI,CAAC;sBAGjD,MAAM,SAAQ,cAAc,KAAQ,OAAO,CAAC,IAAI,CAAC;2BAG5C,MAAM,eAAc,MAAM,KAAS,OAAO,CAAC,IAAI,CAAC;0BAGjD,MAAM,WAAU,MAAM,KAAS,OAAO,CAAC,IAAI,CAAC;CAElE,CAAC;AAIF,eAAO,MAAM,UAAU;gBACZ,OAAO,CAAC,MAAM,CAAC;yBAEN,OAAO,CAAC,WAAW,EAAE,CAAC;2BAGlB,MAAM,QAAQ,MAAM,KAAG,OAAO,CAAC,WAAW,CAAC;qBAMnD,IAAI;sBAED,MAAM,SAAQ,cAAc,KAAQ,OAAO,CAAC,IAAI,CAAC;sBAGjD,MAAM,SAAQ,cAAc,KAAQ,OAAO,CAAC,IAAI,CAAC;2BAG5C,MAAM,eAAc,MAAM,KAAS,OAAO,CAAC,IAAI,CAAC;0BAGjD,MAAM,WAAU,MAAM,KAAS,OAAO,CAAC,IAAI,CAAC;CAElE,CAAC;AAIF,eAAO,MAAM,sBAAsB,oBAElC,CAAC;AAEF,oBAAY,iCAAiC;IAC5C,iCAAiC,oBAAoB;IACrD,0BAA0B,mBAAmB;IAC7C,+BAA+B,kBAAkB;CACjD"}
package/dist/index.js CHANGED
@@ -22,8 +22,8 @@ export const USBPrinter = {
22
22
  closeConn: () => NativeUSBPrinterModule.closeConn(),
23
23
  printText: (text, opts = {}) => NativeUSBPrinterModule.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 @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/E,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,kBAAkB,CAC3D,sBAAsB,CACtB,CAAC;AAEF,MAAM,CAAN,IAAY,iCAIX;AAJD,WAAY,iCAAiC;IAC5C,0FAAqD,CAAA;IACrD,kFAA6C,CAAA;IAC7C,sFAAiD,CAAA;AAClD,CAAC,EAJW,iCAAiC,KAAjC,iCAAiC,QAI5C"}
@@ -131,6 +131,7 @@ RCT_EXPORT_METHOD(printRawData:(NSString *)base64Data
131
131
  }
132
132
 
133
133
  RCT_EXPORT_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:150 paddingX:250];
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
  {
@@ -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:150 paddingX:250];
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
  {
@@ -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.0.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",
@@ -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
  }
@@ -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
  }
@@ -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 ──────────────────────────────────────────────────────────────────