@@ -11,79 +11,72 @@ import {
1111} from "react-native" ;
1212import {
1313 connect ,
14- cutPaper ,
15- disconnect ,
1614 ESCPOSConst ,
17- printerCheck ,
18- printQRCode ,
19- printText ,
2015 searchCitizenPrinter ,
21- setEncoding ,
22- status ,
2316 type CitizenPrinerInfo ,
2417 type CitizenPrinerWiFiInfo ,
2518} from "react-native-citizen-escposprinter" ;
2619
2720const testPrint = async ( connectType : number , address ?: string ) => {
28- await connect ( connectType , address ) ;
21+ const printer = await connect ( connectType , address ) ;
2922 console . log ( "✅ connected:" , address ) ;
30- await printerCheck ( ) ;
23+ await printer . printerCheck ( ) ;
3124 console . log ( "✅ printerCheck" ) ;
32- const printerStatus = await status ( ) ;
33- await setEncoding ( "UTF-8" ) ;
25+ const printerStatus = await printer . status ( ) ;
26+ await printer . setEncoding ( "UTF-8" ) ;
3427 console . log ( "✅ status" , printerStatus ) ;
35- await printText ( "Hello World!你好世界!\n" ) ;
36- await printText (
28+ await printer . printText ( "Hello World!你好世界!\n" ) ;
29+ await printer . printText (
3730 "Hello World!你好世界!\n" ,
3831 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
3932 ESCPOSConst . CMP_FNT_DEFAULT ,
4033 ESCPOSConst . CMP_TXT_2WIDTH | ESCPOSConst . CMP_TXT_2HEIGHT ,
4134 ) ;
42- await printText (
35+ await printer . printText (
4336 "Hello World!你好世界!\n" ,
4437 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
4538 ESCPOSConst . CMP_FNT_DEFAULT ,
4639 ESCPOSConst . CMP_TXT_3WIDTH | ESCPOSConst . CMP_TXT_3HEIGHT ,
4740 ) ;
48- await printText (
41+ await printer . printText (
4942 "Hello World!你好世界!\n" ,
5043 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
5144 ESCPOSConst . CMP_FNT_DEFAULT ,
5245 ESCPOSConst . CMP_TXT_4WIDTH | ESCPOSConst . CMP_TXT_4HEIGHT ,
5346 ) ;
54- await printText (
47+ await printer . printText (
5548 "Hello World!你好世界!\n" ,
5649 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
5750 ESCPOSConst . CMP_FNT_DEFAULT ,
5851 ESCPOSConst . CMP_TXT_5WIDTH | ESCPOSConst . CMP_TXT_5HEIGHT ,
5952 ) ;
60- await printText (
53+ await printer . printText (
6154 "Hello World!你好世界!\n" ,
6255 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
6356 ESCPOSConst . CMP_FNT_DEFAULT ,
6457 ESCPOSConst . CMP_TXT_6WIDTH | ESCPOSConst . CMP_TXT_6HEIGHT ,
6558 ) ;
66- await printText (
59+ await printer . printText (
6760 "Hello World!你好世界!\n" ,
6861 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
6962 ESCPOSConst . CMP_FNT_DEFAULT ,
7063 ESCPOSConst . CMP_TXT_7WIDTH | ESCPOSConst . CMP_TXT_7HEIGHT ,
7164 ) ;
72- await printText (
65+ await printer . printText (
7366 "Hello World!你好世界!\n" ,
7467 ESCPOSConst . CMP_ALIGNMENT_LEFT ,
7568 ESCPOSConst . CMP_FNT_DEFAULT ,
7669 ESCPOSConst . CMP_TXT_8WIDTH | ESCPOSConst . CMP_TXT_8HEIGHT ,
7770 ) ;
78- await printQRCode (
71+ await printer . printQRCode (
7972 "https://www.google.com" ,
8073 8 ,
8174 ESCPOSConst . CMP_QRCODE_EC_LEVEL_H ,
8275 ) ;
8376 console . log ( "✅ printText" ) ;
84- await cutPaper ( ESCPOSConst . CMP_CUT_FULL_PREFEED ) ;
77+ await printer . cutPaper ( ESCPOSConst . CMP_CUT_FULL_PREFEED ) ;
8578 console . log ( "✅ cutPaper" ) ;
86- await disconnect ( ) ;
79+ await printer . disconnect ( ) ;
8780 console . log ( "✅ disconnect" ) ;
8881} ;
8982
0 commit comments