@connexup/react-native-xprinter 0.1.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.
Files changed (145) hide show
  1. package/LICENSE +20 -0
  2. package/NativeXPrinter.podspec +23 -0
  3. package/README.md +24 -0
  4. package/android/build.gradle +73 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/libs/printer-lib-3.4.7.aar +0 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/connexup/xprinter/Errors.kt +11 -0
  9. package/android/src/main/java/com/connexup/xprinter/Util.kt +106 -0
  10. package/android/src/main/java/com/connexup/xprinter/XPrinterPackage.kt +77 -0
  11. package/android/src/main/java/com/connexup/xprinter/esc/Convert.kt +211 -0
  12. package/android/src/main/java/com/connexup/xprinter/esc/XPrinterESCModule.kt +1995 -0
  13. package/android/src/main/java/com/connexup/xprinter/printer/Convert.kt +46 -0
  14. package/android/src/main/java/com/connexup/xprinter/printer/DeviceConnection.kt +14 -0
  15. package/android/src/main/java/com/connexup/xprinter/printer/Printers.kt +153 -0
  16. package/android/src/main/java/com/connexup/xprinter/printer/XPrinterPrinterModule.kt +295 -0
  17. package/android/src/main/java/com/connexup/xprinter/tspl/Convert.kt +151 -0
  18. package/android/src/main/java/com/connexup/xprinter/tspl/XPrinterTSPLModule.kt +1408 -0
  19. package/android/src/main/java/com/connexup/xprinter/utils/XPrinterUtilsModule.kt +54 -0
  20. package/ios/ESC/ESCConvert.swift +283 -0
  21. package/ios/ESC/Models/RCTESCPrintBarCodeRequest.swift +23 -0
  22. package/ios/ESC/Models/RCTESCPrintBitmapRequest.swift +23 -0
  23. package/ios/ESC/Models/RCTESCPrintPDF417Request.swift +27 -0
  24. package/ios/ESC/Models/RCTESCPrintQRCodeRequest.swift +19 -0
  25. package/ios/ESC/Models/RCTESCPrintTableBarcode.swift +23 -0
  26. package/ios/ESC/Models/RCTESCPrintTableRequest.swift +19 -0
  27. package/ios/ESC/Models/RCTESCPrintTableRow.swift +19 -0
  28. package/ios/ESC/Models/RCTESCPrintTextRequest.swift +21 -0
  29. package/ios/ESC/Models/RCTESCPrintTextSizeRequest.swift +17 -0
  30. package/ios/ESC/Models/RCTESCSelectBitmapModelRequest.swift +17 -0
  31. package/ios/ESC/Models/RCTESCSetNetAllRequest.swift +19 -0
  32. package/ios/ESC/Models/RCTESCSetPrintAreaRequest.swift +19 -0
  33. package/ios/ESC/Models/RCTESCSetTextStyleRequest.swift +17 -0
  34. package/ios/ESC/Models/RCTESCWifiConfigRequest.swift +23 -0
  35. package/ios/ESC/NativeXPrinterESC.swift +1339 -0
  36. package/ios/ESC/RCTNativeXPrinterESC.h +10 -0
  37. package/ios/ESC/RCTNativeXPrinterESC.mm +541 -0
  38. package/ios/Errors.swift +11 -0
  39. package/ios/NativeErrorInfo.swift +21 -0
  40. package/ios/Printer/Connecter.swift +214 -0
  41. package/ios/Printer/Models/RCTDeviceConnectStatusChangeEvent.swift +19 -0
  42. package/ios/Printer/Models/RCTNetDevice.swift +21 -0
  43. package/ios/Printer/Models/RCTUSBDevice.swift +17 -0
  44. package/ios/Printer/Models/RCTUpdateUdpNetConfigRequest.swift +21 -0
  45. package/ios/Printer/NativeXPrinterPrinter.swift +209 -0
  46. package/ios/Printer/Printers.swift +59 -0
  47. package/ios/Printer/RCTNativeXPrinterPrinter.h +12 -0
  48. package/ios/Printer/RCTNativeXPrinterPrinter.mm +123 -0
  49. package/ios/PrinterSDK/Headers/CPCLCommand.h +324 -0
  50. package/ios/PrinterSDK/Headers/KDS_Log.h +47 -0
  51. package/ios/PrinterSDK/Headers/LabelDocument.h +32 -0
  52. package/ios/PrinterSDK/Headers/LabelImageTranster.h +19 -0
  53. package/ios/PrinterSDK/Headers/POSBLEManager.h +164 -0
  54. package/ios/PrinterSDK/Headers/POSCommand.h +760 -0
  55. package/ios/PrinterSDK/Headers/POSImageTranster.h +34 -0
  56. package/ios/PrinterSDK/Headers/POSPrinter.h +47 -0
  57. package/ios/PrinterSDK/Headers/POSPrinterSDK.h +13 -0
  58. package/ios/PrinterSDK/Headers/POSWIFIManager.h +162 -0
  59. package/ios/PrinterSDK/Headers/PTable.h +50 -0
  60. package/ios/PrinterSDK/Headers/PrinterProfile.h +28 -0
  61. package/ios/PrinterSDK/Headers/TSCBLEManager.h +142 -0
  62. package/ios/PrinterSDK/Headers/TSCCommand.h +701 -0
  63. package/ios/PrinterSDK/Headers/TSCPrinterSDK.h +15 -0
  64. package/ios/PrinterSDK/Headers/TSCWIFIManager.h +99 -0
  65. package/ios/PrinterSDK/Headers/WIFIConnecter.h +131 -0
  66. package/ios/PrinterSDK/Headers/ZPLCommand.h +372 -0
  67. package/ios/PrinterSDK/libPrinterSDK.a +0 -0
  68. package/ios/TSPL/Models/RCTTSPLBarRequest.swift +19 -0
  69. package/ios/TSPL/Models/RCTTSPLBarcodeRequest.swift +29 -0
  70. package/ios/TSPL/Models/RCTTSPLBitmapCompressionRequest.swift +25 -0
  71. package/ios/TSPL/Models/RCTTSPLBitmapRequest.swift +25 -0
  72. package/ios/TSPL/Models/RCTTSPLBoxRequest.swift +21 -0
  73. package/ios/TSPL/Models/RCTTSPLEraseRequest.swift +19 -0
  74. package/ios/TSPL/Models/RCTTSPLPDFBase64Request.swift +21 -0
  75. package/ios/TSPL/Models/RCTTSPLPutBMPRequest.swift +17 -0
  76. package/ios/TSPL/Models/RCTTSPLQRCodeRequest.swift +29 -0
  77. package/ios/TSPL/Models/RCTTSPLReverseRequest.swift +19 -0
  78. package/ios/TSPL/Models/RCTTSPLTextRequest.swift +25 -0
  79. package/ios/TSPL/NativeXPrinterTSPL.swift +831 -0
  80. package/ios/TSPL/RCTNativeXPrinterTSPL.h +10 -0
  81. package/ios/TSPL/RCTNativeXPrinterTSPL.mm +445 -0
  82. package/ios/TSPL/TSPLConvert.swift +140 -0
  83. package/ios/Utils/Models/RCTCheckIsPureWhiteImageRequest.swift +16 -0
  84. package/ios/Utils/NativeXPrinterUtils.swift +17 -0
  85. package/ios/Utils/RCTNativeXPrinterUtils.h +10 -0
  86. package/ios/Utils/RCTNativeXPrinterUtils.mm +38 -0
  87. package/ios/Utils.swift +126 -0
  88. package/lib/module/esc/NativeXPrinterESC.js +218 -0
  89. package/lib/module/esc/NativeXPrinterESC.js.map +1 -0
  90. package/lib/module/esc/index.js +324 -0
  91. package/lib/module/esc/index.js.map +1 -0
  92. package/lib/module/index.js +8 -0
  93. package/lib/module/index.js.map +1 -0
  94. package/lib/module/package.json +1 -0
  95. package/lib/module/printer/NativeXPrinterPrinter.js +30 -0
  96. package/lib/module/printer/NativeXPrinterPrinter.js.map +1 -0
  97. package/lib/module/printer/index.js +110 -0
  98. package/lib/module/printer/index.js.map +1 -0
  99. package/lib/module/tspl/NativeXPrinterTSPL.js +143 -0
  100. package/lib/module/tspl/NativeXPrinterTSPL.js.map +1 -0
  101. package/lib/module/tspl/index.js +347 -0
  102. package/lib/module/tspl/index.js.map +1 -0
  103. package/lib/module/type.js +12 -0
  104. package/lib/module/type.js.map +1 -0
  105. package/lib/module/util.js +4 -0
  106. package/lib/module/util.js.map +1 -0
  107. package/lib/module/utils/NativeXPrinterUtils.js +5 -0
  108. package/lib/module/utils/NativeXPrinterUtils.js.map +1 -0
  109. package/lib/module/utils/index.js +17 -0
  110. package/lib/module/utils/index.js.map +1 -0
  111. package/lib/typescript/package.json +1 -0
  112. package/lib/typescript/src/esc/NativeXPrinterESC.d.ts +343 -0
  113. package/lib/typescript/src/esc/NativeXPrinterESC.d.ts.map +1 -0
  114. package/lib/typescript/src/esc/index.d.ts +122 -0
  115. package/lib/typescript/src/esc/index.d.ts.map +1 -0
  116. package/lib/typescript/src/index.d.ts +6 -0
  117. package/lib/typescript/src/index.d.ts.map +1 -0
  118. package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts +61 -0
  119. package/lib/typescript/src/printer/NativeXPrinterPrinter.d.ts.map +1 -0
  120. package/lib/typescript/src/printer/index.d.ts +32 -0
  121. package/lib/typescript/src/printer/index.d.ts.map +1 -0
  122. package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts +261 -0
  123. package/lib/typescript/src/tspl/NativeXPrinterTSPL.d.ts.map +1 -0
  124. package/lib/typescript/src/tspl/index.d.ts +128 -0
  125. package/lib/typescript/src/tspl/index.d.ts.map +1 -0
  126. package/lib/typescript/src/type.d.ts +9 -0
  127. package/lib/typescript/src/type.d.ts.map +1 -0
  128. package/lib/typescript/src/util.d.ts +2 -0
  129. package/lib/typescript/src/util.d.ts.map +1 -0
  130. package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts +10 -0
  131. package/lib/typescript/src/utils/NativeXPrinterUtils.d.ts.map +1 -0
  132. package/lib/typescript/src/utils/index.d.ts +9 -0
  133. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  134. package/package.json +178 -0
  135. package/src/esc/NativeXPrinterESC.ts +516 -0
  136. package/src/esc/index.ts +489 -0
  137. package/src/index.ts +5 -0
  138. package/src/printer/NativeXPrinterPrinter.ts +84 -0
  139. package/src/printer/index.ts +160 -0
  140. package/src/tspl/NativeXPrinterTSPL.ts +388 -0
  141. package/src/tspl/index.ts +535 -0
  142. package/src/type.ts +11 -0
  143. package/src/util.ts +1 -0
  144. package/src/utils/NativeXPrinterUtils.ts +14 -0
  145. package/src/utils/index.ts +27 -0
@@ -0,0 +1,324 @@
1
+ //
2
+ // CPCLCommand.h
3
+ // Printer
4
+ //
5
+ // Created by apple on 2022/9/20.
6
+ // Copyright © 2022 Admin. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <UIKit/UIKit.h>
11
+
12
+ NS_ASSUME_NONNULL_BEGIN
13
+
14
+ //Rotation
15
+ typedef NS_ENUM(NSInteger, CPCLRotation) {
16
+ ROTA_0 = 0,
17
+ ROTA_90,
18
+ ROTA_180,
19
+ ROTA_270
20
+ };
21
+
22
+ //Font
23
+ typedef NS_ENUM(NSInteger, CPCLFont) {
24
+ FNT_0 = 0,
25
+ FNT_1 = 1,
26
+ FNT_2 = 2,
27
+ FNT_3 = 3,
28
+ FNT_4 = 4,
29
+ FNT_5 = 5,
30
+ FNT_6 = 6,
31
+ FNT_7 = 7,
32
+ FNT_24 = 24,
33
+ FNT_55 = 55
34
+ };
35
+
36
+ //BarCode
37
+ typedef NS_ENUM(NSInteger, CPCLBarCode) {
38
+ BC_128 = 0,
39
+ BC_UPCA,
40
+ BC_UPCE,
41
+ BC_EAN13,
42
+ BC_EAN8,
43
+ BC_39,
44
+ BC_93,
45
+ BC_CODABAR
46
+ };
47
+
48
+ //Bar Code Ratio
49
+ typedef NS_ENUM(NSInteger, CPCLBarCodeRatio) {
50
+ BCR_RATIO_0 = 0,
51
+ BCR_RATIO_1 = 1,
52
+ BCR_RATIO_2 = 2,
53
+ BCR_RATIO_3 = 3,
54
+ BCR_RATIO_4 = 4,
55
+ BCR_RATIO_20 = 20,
56
+ BCR_RATIO_21 = 21,
57
+ BCR_RATIO_22 = 22,
58
+ BCR_RATIO_23 = 23,
59
+ BCR_RATIO_24 = 24,
60
+ BCR_RATIO_25 = 25,
61
+ BCR_RATIO_26 = 26,
62
+ BCR_RATIO_27 = 27,
63
+ BCR_RATIO_28 = 28,
64
+ BCR_RATIO_29 = 29,
65
+ BCR_RATIO_30 = 30
66
+ };
67
+
68
+ //QR Code Mode
69
+ typedef NS_ENUM(NSInteger, CPCLQRCodeMode) {
70
+ CODE_MODE_ORG = 1,
71
+ CODE_MODE_ENHANCE = 2
72
+ };
73
+
74
+ //Alignment
75
+ typedef NS_ENUM(NSInteger, CPCLAlignment) {
76
+ ALIGNMENT_LEFT = 0,
77
+ ALIGNMENT_CENTER,
78
+ ALIGNMENT_RIGHT
79
+ };
80
+
81
+ @interface CPCLCommand : NSObject
82
+
83
+ /**
84
+ * 标签初始化
85
+ * @param height 标签高度
86
+ * @return data
87
+ */
88
+ + (NSData *)initLabelWithHeight:(int)height;
89
+
90
+ /**
91
+ * 标签初始化
92
+ * @param height 标签高度
93
+ * @param count 标签数量
94
+ * @return data
95
+ */
96
+ + (NSData *)initLabelWithHeight:(int)height count:(int)count;
97
+
98
+
99
+ /**
100
+ * 标签初始化
101
+ * @param height 标签高度
102
+ * @param count 标签数量
103
+ * @param offsetx 横向偏移位置
104
+ * @return data
105
+ */
106
+ + (NSData *)initLabelWithHeight:(int)height count:(int)count offsetx:(int)offsetx;
107
+
108
+ /**
109
+ * 设置字体放大倍数
110
+ * @param w 宽度放大倍数 1~16
111
+ * @param h 高度放大倍数 1~16
112
+ * @return data
113
+ */
114
+ + (NSData *)setmagWithw:(int)w h:(int)h;
115
+
116
+ /**
117
+ * 设置字段的对齐方式 default:左对齐所有字段。
118
+ * @param alignment CPCLAlignment
119
+ * @return data
120
+ */
121
+ + (NSData *)setAlignment:(CPCLAlignment)alignment;
122
+
123
+
124
+ /**
125
+ * 设置字段的对齐方式 default:左对齐所有字段。
126
+ * @param alignment CPCLAlignment
127
+ * @param end 对齐的结束点
128
+ * @return data
129
+ */
130
+ + (NSData *)setAlignment:(CPCLAlignment)alignment end:(int)end;
131
+
132
+ /**
133
+ * 设置打印速度
134
+ * @param level 速度级别 0~5
135
+ * @return data
136
+ */
137
+ + (NSData *)setSpeedLevel:(int)level;
138
+
139
+ /**
140
+ * 设置打印宽度
141
+ * @param width 页面的单位宽度
142
+ * @return data
143
+ */
144
+ + (NSData *)setPageWidth:(int)width;
145
+
146
+ /**
147
+ * 设置蜂鸣发出时间
148
+ * @param length 蜂鸣持续时间,以1/8秒为单位,例如16表示发声时间为2秒
149
+ * @return data
150
+ */
151
+ + (NSData *)setBeepLength:(int)length;
152
+
153
+ /**
154
+ * 设置字符编码
155
+ * @param encoding NSStringEncoding
156
+ */
157
+ + (void)setStringEncoding:(NSStringEncoding)encoding;
158
+
159
+ /**
160
+ 绘制文本内容
161
+ @param x x-coordinate
162
+ @param y y-coordinate
163
+ @param content 内容
164
+ @return data
165
+ */
166
+ + (NSData *)drawTextWithx:(int)x y:(int)y content:(NSString *)content;
167
+
168
+ /**
169
+ 绘制文本内容
170
+ @param x x-coordinate
171
+ @param y y-coordinate
172
+ @param font FontType
173
+ @param content 内容
174
+ @return data
175
+ */
176
+ + (NSData *)drawTextWithx:(int)x y:(int)y font:(CPCLFont)font content:(NSString *)content;
177
+
178
+ /**
179
+ 绘制文本内容
180
+ @param x x-coordinate
181
+ @param y y-coordinate
182
+ @param font FontType
183
+ @param rotation RotationType
184
+ @param content 内容
185
+ @return data
186
+ */
187
+ + (NSData *)drawTextWithx:(int)x y:(int)y rotation:(CPCLRotation)rotation font:(CPCLFont)font content:(NSString *)content;
188
+
189
+ /**
190
+ 指示打印机在一页打印结束后切换至下一页顶部
191
+ @return data
192
+ */
193
+ + (NSData *)form;
194
+
195
+ /**
196
+ 结束命令 将会启动打印
197
+ @return data
198
+ */
199
+ + (NSData *)print;
200
+
201
+ /**
202
+ 绘制一维码
203
+ @param x x-coordinate
204
+ @param y y-coordinate
205
+ @param codeType CPCLBarCode
206
+ @param height 条码高度
207
+ @param content 内容
208
+ @return data
209
+ */
210
+ + (NSData *)drawBarcodeWithx:(int)x y:(int)y codeType:(CPCLBarCode)codeType height:(int)height content:(NSString *)content;
211
+
212
+ /**
213
+ 绘制一维码
214
+ @param x x-coordinate
215
+ @param y y-coordinate
216
+ @param codeType CPCLBarCode
217
+ @param height 条码高度
218
+ @param ratio 宽条与窄条的比率,默认 BCR_RATIO_1
219
+ @param content 内容
220
+ @return data
221
+ */
222
+ + (NSData *)drawBarcodeWithx:(int)x y:(int)y codeType:(CPCLBarCode)codeType height:(int)height ratio:(CPCLBarCodeRatio)ratio content:(NSString *)content;
223
+
224
+ /**
225
+ 绘制一维码
226
+ @param x x-coordinate
227
+ @param y y-coordinate
228
+ @param codeType CPCLBarCode
229
+ @param height 条码高度
230
+ @param content 内容
231
+ @return data
232
+ */
233
+ + (NSData *)drawBarcodeVerticalWithx:(int)x y:(int)y codeType:(CPCLBarCode)codeType height:(int)height content:(NSString *)content;
234
+
235
+ /**
236
+ 绘制一维码
237
+ @param x x-coordinate
238
+ @param y y-coordinate
239
+ @param codeType CPCLBarCode
240
+ @param height 条码高度
241
+ @param ratio 宽条与窄条的比率,默认 BCR_RATIO_1
242
+ @param content 内容
243
+ @return data
244
+ */
245
+ + (NSData *)drawBarcodeVerticalWithx:(int)x y:(int)y codeType:(CPCLBarCode)codeType height:(int)height ratio:(CPCLBarCodeRatio)ratio content:(NSString *)content;
246
+
247
+ /**
248
+ 添加条码注释
249
+ @param offsetx 文本距离条码的单位偏移量
250
+ */
251
+ + (NSData *)barcodeText:(int)offsetx;
252
+
253
+
254
+ /**
255
+ * 取消条码注释
256
+ */
257
+ + (NSData *)barcodeTextOff;
258
+
259
+ /**
260
+ 绘制二维码
261
+ @param x x-coordinate
262
+ @param y y-coordinate
263
+ @param content 内容
264
+ @return data
265
+ */
266
+ + (NSData *)drawQRCodeWithx:(int)x y:(int)y content:(NSString *)content;
267
+
268
+ /**
269
+ 绘制二维码
270
+ @param x x-coordinate
271
+ @param y y-coordinate
272
+ @param codeModel CPCLBarCode
273
+ @param cellWidth 单元格大小 1~32 default:6
274
+ @param content 内容
275
+ @return data
276
+ */
277
+ + (NSData *)drawQRCodeWithx:(int)x y:(int)y codeModel:(CPCLQRCodeMode)codeModel cellWidth:(int)cellWidth content:(NSString *)content;
278
+
279
+ /**
280
+ 绘制图片
281
+ @param x x-coordinate
282
+ @param y y-coordinate
283
+ @param image UIImage
284
+ @return data
285
+ */
286
+ + (NSData *)drawImageWithx:(int)x y:(int)y image:(UIImage *)image;
287
+
288
+ /**
289
+ 绘制矩形
290
+ @param x x-coordinate
291
+ @param y y-coordinate
292
+ @param width 矩形宽度
293
+ @param height 矩形高度
294
+ @param thickness 矩形线宽
295
+ @return data
296
+ */
297
+ + (NSData *)drawBoxWithx:(int)x y:(int)y width:(int)width height:(int)height thickness:(int)thickness;
298
+
299
+ /**
300
+ 绘制线条
301
+ @param x 线条起始横坐标 单位为点
302
+ @param y 线条起始纵坐标 单位为点
303
+ @param xend 线条结束横坐标 单位为点
304
+ @param yend 线条结束纵坐标 单位为点
305
+ @param width 线条宽度
306
+ @return data
307
+ */
308
+ + (NSData *)drawLineWithx:(int)x y:(int)y xend:(int)xend yend:(int)yend width:(int)width;
309
+
310
+ /**
311
+ 将指定区域的数据黑白反向显示
312
+ @param x 反显区域起始横坐标 单位为点
313
+ @param y 反显区域起始纵坐标 单位为点
314
+ @param xend 反显区域结束横坐标 单位为点
315
+ @param yend 反显区域结束纵坐标 单位为点
316
+ @param width 反显区域宽度 单位为点
317
+ @return data
318
+ */
319
+ + (NSData *)drawInverseLineWithx:(int)x y:(int)y xend:(int)xend yend:(int)yend width:(int)width;
320
+
321
+
322
+ @end
323
+
324
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,47 @@
1
+ //
2
+ // KDS_Log.h
3
+ // Printer
4
+ //
5
+ // Created by Apple Mac mini intel on 2022/11/4.
6
+ // Copyright © 2022 Admin. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ /**
14
+ * 自定义Log,可配置开关(用于替换NSLog)
15
+ */
16
+ #define KDS_Log(format,...) CustomLog(__FUNCTION__,__LINE__,format,##__VA_ARGS__)
17
+
18
+ /**
19
+ * 自定义Log
20
+ * @warning 外部可直接调用 KDS_Log
21
+ *
22
+ * @param func 方法名
23
+ * @param lineNumber 行号
24
+ * @param format Log内容
25
+ * @param ... 个数可变的Log参数
26
+ */
27
+ void CustomLog(const char *func, int lineNumber, NSString *format, ...);
28
+
29
+ @interface KDS_Log : NSObject
30
+
31
+ /**
32
+ * Log 输出开关 (默认关闭)
33
+ *
34
+ * @param flag 是否开启
35
+ */
36
+ + (void)setLogEnable:(BOOL)flag;
37
+
38
+ /**
39
+ * 是否开启了 Log 输出
40
+ *
41
+ * @return Log 开关状态
42
+ */
43
+ + (BOOL)logEnable;
44
+
45
+ @end
46
+
47
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,32 @@
1
+ //
2
+ // LabelDocument.h
3
+ // Printer
4
+ //
5
+ // Created by Apple Mac mini intel on 2023/3/21.
6
+ // Copyright © 2023 Admin. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import <UIKit/UIKit.h>
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ //Rotation
14
+ typedef NS_ENUM(NSInteger, DocErrorCode) {
15
+ DocSuccess = 0,
16
+ CGPDFDocumentRefNULL,
17
+ PageNumberExceeds,
18
+ };
19
+
20
+ typedef void (^ParsingDataCallBackBlock) (NSMutableArray<UIImage *> *sourceImages,DocErrorCode errorCode);
21
+
22
+ @interface LabelDocument : NSObject
23
+ // 获取当前PDF文件总页数
24
+ + (int)getPDFPages:(NSString *)filePath pdfPassword:(nullable NSString *)password;
25
+ // 解析文档,获取对应的图像数据源集合
26
+ + (void)parsingDoc:(NSString *)filePath start:(int)startPage end:(int)endPage password:(nullable NSString *)password DataCallBack:(ParsingDataCallBackBlock)dataBlock;
27
+ // 根据宽度缩放对应的图像数据源
28
+ + (UIImage *)imageWithScaleImage:(UIImage *)image andScaleWidth:(int)width;
29
+
30
+ @end
31
+
32
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,19 @@
1
+ //
2
+ // UIImageTranster.h
3
+ // Printer
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <UIKit/UIKit.h>
8
+
9
+ typedef enum {
10
+ TSPL_PRINT = 0, //tspl打印
11
+ ZPL_PRINT = 1, //zpl打印
12
+ CPCL_PRINT = 2, //cpcl打印
13
+ } PrintCommand;
14
+
15
+ @interface LabelImageTranster : NSObject
16
+
17
+ + (NSData *)dataWithImage: (UIImage *)mImage printType: (PrintCommand)printType;
18
+
19
+ @end
@@ -0,0 +1,164 @@
1
+ //
2
+ // POSBLEManager.h
3
+ // Printer
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+ #import <CoreBluetooth/CoreBluetooth.h>
8
+
9
+ @protocol POSBLEManagerDelegate <NSObject>
10
+ @optional
11
+ /**
12
+ * found peripheral list
13
+ */
14
+ - (void)POSbleUpdatePeripheralList:(NSArray *)peripherals RSSIList:(NSArray *)rssiList;
15
+ /**
16
+ * connect success
17
+ */
18
+ - (void)POSbleConnectPeripheral:(CBPeripheral *)peripheral;
19
+ /**
20
+ * connect fail
21
+ */
22
+ - (void)POSbleFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
23
+ /**
24
+ * disconnect
25
+ */
26
+ - (void)POSbleDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
27
+ /**
28
+ * send data success
29
+ */
30
+ - (void)POSbleWriteValueForCharacteristic:(CBCharacteristic *)character error:(NSError *)error;
31
+ /**
32
+ * receive printer data
33
+ */
34
+ - (void)POSbleReceiveValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error;
35
+ /**
36
+ * bleCentralManager state update
37
+ */
38
+ - (void)POSbleCentralManagerDidUpdateState:(NSInteger)state;
39
+
40
+ @end
41
+
42
+ /****************************************************************************************************/
43
+
44
+ typedef void (^POSBLEManagerReceiveCallBackBlock)(CBCharacteristic *characteristic, NSError *error);
45
+ typedef void (^POSBLEManagerWriteCallBackBlock) (CBCharacteristic *characteristic, NSError *error);
46
+ typedef void (^POSBLEPrinterStatusBlock)(NSData *status);
47
+ typedef void (^POSBLEPrinterSNBlock)(NSString *sn);
48
+ typedef void (^POSBLEPrinterCheckBlock)(NSData *check);
49
+
50
+ /****************************************************************************************************/
51
+
52
+ @interface POSBLEManager : NSObject
53
+
54
+ // bt name
55
+ @property (nonatomic, copy) NSString *name;
56
+ // connect status
57
+ @property (nonatomic, assign) BOOL isConnecting;
58
+ // scan status
59
+ @property (nonatomic, assign) BOOL isScaning;
60
+ // peripheral write
61
+ @property (nonatomic, strong) CBPeripheral *writePeripheral;
62
+ // write characteristic
63
+ @property (nonatomic, strong) CBCharacteristic *write_characteristic;
64
+ // read characteristic
65
+ @property (nonatomic, strong) CBCharacteristic *read_characteristic;
66
+ // notify characteristic
67
+ @property (nonatomic, strong) CBCharacteristic *notify_characteristic;
68
+ // search filter printer through uuid
69
+ @property (nonatomic, strong) CBUUID *searchFilterUUID;
70
+ // characteristic uuid
71
+ @property (nonatomic, strong) CBUUID *characteristicUUID;
72
+
73
+ @property (nonatomic, weak) id<POSBLEManagerDelegate> delegate;
74
+
75
+ @property (nonatomic, copy) POSBLEManagerReceiveCallBackBlock receiveBlock;
76
+ @property (nonatomic, copy) POSBLEManagerWriteCallBackBlock writeBlock;
77
+ @property (nonatomic, copy) POSBLEPrinterStatusBlock statusBlock;
78
+ @property (nonatomic, copy) POSBLEPrinterSNBlock snBlock;
79
+ @property (nonatomic, copy) POSBLEPrinterCheckBlock checkBlock;
80
+
81
+ /**
82
+ * singleton
83
+ */
84
+ + (instancetype)sharedInstance;
85
+
86
+ /**
87
+ * remove a delegate
88
+ */
89
+ - (void)removeDelegate:(id<POSBLEManagerDelegate>)delegate;
90
+
91
+ /**
92
+ * remove all delegates
93
+ */
94
+ - (void)removeAllDelegates;
95
+
96
+ /**
97
+ * start scan
98
+ */
99
+ - (void)startScan;
100
+
101
+ /**
102
+ * stop scan
103
+ */
104
+ - (void)stopScan;
105
+
106
+ /**
107
+ * connect special one
108
+ */
109
+ - (void)connectDevice:(CBPeripheral *)peripheral;
110
+
111
+ /**
112
+ * disconnect manual
113
+ */
114
+ - (void)disconnectRootPeripheral;
115
+
116
+ /**
117
+ * send command
118
+ */
119
+ - (void)writeCommandWithData:(NSData *)data;
120
+
121
+ /**
122
+ * send command data with receive callback
123
+ */
124
+ - (void)writeCommandWithData:(NSData *)data receiveCallBack:(POSBLEManagerReceiveCallBackBlock)receiveBlock;
125
+
126
+ /**
127
+ * send command data with write callback
128
+ */
129
+ - (void)writeCommandWithData:(NSData *)data writeCallBack:(POSBLEManagerWriteCallBackBlock)writeBlock;
130
+
131
+ /**
132
+ * set bluetooth name and key
133
+ */
134
+ - (void)setBluetoothNameAndKeyWith:(NSString *)btName btKey:(NSString *)btKey;
135
+
136
+ /**
137
+ * check connect status
138
+ */
139
+ - (BOOL)printerIsConnect;
140
+
141
+ /**
142
+ * printer status
143
+ * 查询当前打印机常用状态(正常/缺纸/开盖等)
144
+ */
145
+ - (void)printerStatus:(POSBLEPrinterStatusBlock)statusBlock;
146
+
147
+ /**
148
+ * printer check
149
+ * 这个方法用于查询打印机所有状态
150
+ * type = 1 打印机状态 type = 2 脱机状态 type = 3 错误状态 type = 4 传送纸状态
151
+ */
152
+ - (void)printerCheck:(int)type checkBlock:(POSBLEPrinterCheckBlock)checkBlock;
153
+
154
+ /**
155
+ * printer sn code
156
+ */
157
+ - (void)printerSN:(POSBLEPrinterSNBlock)snBlock;
158
+
159
+ /**
160
+ * get copyright
161
+ */
162
+ + (NSString *)GetCopyRight;
163
+
164
+ @end