一门APP开发教程

标题: 一门APP使用JS调用中崎打印机说明 [打印本页]

作者: 曾清    时间: 2020-2-17 14:58
标题: 一门APP使用JS调用中崎打印机说明
一门APP使用JS调用中崎打印机说明
DEMO参考:https://www.yimenapp.com/doc/demo_zqprinter.cshtml

♦ 中崎官网 http://www.zonerich.com
♦ js API 说明:
♦ 所有API接口具有统一的参数格式 function(options, callback);
♦ options 为 json 参数,没有参数传 null 即可;
♦ options 的 json 字段名称与类型和 官方 Android SDK 文档 的参数名与类型相同;
♦ callback 为回调函数 function(text),统一返回字符串类型;
♦ byte[], Bitmap 类型的参数或返回值统一使用 BASE64 编码;
♦ 必要的时候请自行转换数据类型;

中崎小票打印机(ZQPrinterSDK)
SDK_Version
  1. jsBridge.zqprinter.SDK_Version(null
  2. , function(text) {
  3.     alert(text);
  4. });
复制代码



Prn_GetPortList
  1. jsBridge.zqprinter.Prn_GetPortList({
  2.   nPortType: 2
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码


Prn_Connect
  1. jsBridge.zqprinter.Prn_Connect({
  2.   strAddr: "USB0"
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_Disconnect
  1. jsBridge.zqprinter.Prn_Disconnect(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_PrinterInit
  1. jsBridge.zqprinter.Prn_PrinterInit(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_Status
  1. jsBridge.zqprinter.Prn_Status(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_PowerStatus
  1. jsBridge.zqprinter.Prn_PowerStatus(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_PrintText
  1. jsBridge.zqprinter.Prn_PrintText({
  2.   Data: "Hello world\r\n",
  3.   Alignment: 0,
  4.   Attribute: 0,
  5.   TextSize: 0
  6. }, function(text) {
  7.   alert(text);
  8. });
复制代码



Prn_PrintEscText
  1. jsBridge.zqprinter.Prn_PrintEscText({
  2.   strPrint: "ESC|bC" //加粗打印
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_PrintString
  1. jsBridge.zqprinter.Prn_PrintString({
  2.   strPrint: "Hello world, 你好,世界。\r\n"
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_PrintBarcode
  1. jsBridge.zqprinter.Prn_PrintBarcode({
  2.   strBarcode: "9771671216014",
  3.   Symbology: 103, // EAN13
  4.   Height: 20,
  5.   Width: 3,
  6.   TextPosition: 2
  7. }, function(text) {
  8.   alert(text);
  9. });
复制代码



Prn_PrintQRCode
  1. jsBridge.zqprinter.Prn_PrintQRCode({
  2.   nMode:   1,
  3.   strCode: "https://m.baidu.com"
  4. }, function(text) {
  5.   alert(text);
  6. });
复制代码



Prn_PrintBitmap
  1. jsBridge.zqprinter.Prn_PrintBitmap({
  2.   //图片的 BASE64 编码
  3.   image: "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAFWUlEQVR4Xu2aj21bNxDGjxPUmaDOBHUmSDJB2gnSTNDzBHUm0GWCJhPUmaDOBHUmqDNBnQlY/IJjQLCyeHwSBRkSgQcbenwk77vv/pFMcuQtHbn8cgLgxIAjR+BkAkdOgJMT3IsJqOp5Sul5zvlCRHjO/akJeCciPDcppduc8yczu5/N0GkAqOpZSul1zvlXF3qJLLcpJcs5f5wFxs4BQNsi8ruI/CwiZ43UX1zLtyLSape+hR0/Nt/R10Tk3a6B2CkAqorg2gj+WUTei8i1mUHxblNVgHghIrDnp+qD+5TS1Wq1etcdJNhhJwD4gv9oqP5BRK6iQj+0XmfUlYi8rvrAoF+2HZvxtgZAVdHSqtL6JzS3i8XVoDjImMFz/x2zeGNm10Flr+22FQAuPJqnfYX+ZgbdpzVVxcQAvDRAWDznYgDWCP/CzKDm9OZsuBGRH3yyxSAsAqARHieH8NNjdmMSRBvoX5zkSzMDlKE2DICj/5fbPLQ/37fwRUJ3kLAOJqCAZ6O+ZwkAf7u3R/i90X5DlCBkFnO4NbNnIxQYAkB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aganaokTDwFCD7/dhGav14YtUOeVZepSZ3rUhbBAZa0eGut1xPvlAGNBhGAcMkzWgcwFBcxAAyfsjON79wJRpjhrECr5bo84PBwfoegJXKgXYQlwZoaTaaZQASQQ+ozzQQOSchNazkB8Fg0NWudJwbMQvaxjHtiwGPR1Kx1/gfMJFRfB1SS0QAAAABJRU5ErkJggg==",
  4.   Type : 0
  5. }, function(text) {
  6.   alert(text);
  7. });
复制代码



Prn_CutPaper
  1. jsBridge.zqprinter.Prn_CutPaper({
  2.   nCutMode: 49
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_OpenCashbox
  1. jsBridge.zqprinter.Prn_OpenCashbox({
  2.   iWitch: 0
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_LineFeed
  1. jsBridge.zqprinter.Prn_LineFeed({
  2.   nLine: 3
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_MarkFeed
  1. jsBridge.zqprinter.Prn_MarkFeed(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_SetCharacterSet
  1. jsBridge.zqprinter.Prn_SetCharacterSet({
  2.   strCode: "gb2312"
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_SetInterCharacterSet
  1. jsBridge.zqprinter.Prn_SetInterCharacterSet({
  2.   Value: 0
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码


Prn_SetLineSpacing
  1. jsBridge.zqprinter.Prn_SetLineSpacing({
  2.   nSpace: 8
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_SetFontStyle
  1. jsBridge.zqprinter.Prn_SetFontStyle({
  2.   nStyle: 0
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_SetFontSize
  1. jsBridge.zqprinter.Prn_SetFontSize({
  2.   nSize: 0
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_SetAlignment
  1. jsBridge.zqprinter.Prn_SetAlignment({
  2.   nAlignment: 0
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_SendData
  1. jsBridge.zqprinter.Prn_SendData({
  2.   byData: "" //base64 encoded data
  3. }, function(text) {
  4.   alert(text);
  5. });
复制代码



Prn_ReadData
  1. jsBridge.zqprinter.Prn_ReadData({
  2.   nTimeout: 5000
  3. }, function(text) {
  4.   //返回 base64 encoded data
  5.   alert(text);
  6. });
复制代码



Prn_BeginTransaction
  1. jsBridge.zqprinter.Prn_BeginTransaction(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_EndTransaction
  1. jsBridge.zqprinter.Prn_EndTransaction(null
  2. , function(text) {
  3.   alert(text);
  4. });
复制代码



Prn_GetMsrTrack
  1. jsBridge.zqprinter.Prn_GetMsrTrack({
  2.   nTrack: 1,
  3.   nTimeout: 5000
  4. }, function(text) {
  5.   alert(text);
  6. });
复制代码








欢迎光临 一门APP开发教程 (https://bbs.yimenapp.com/) Powered by Discuz! X3.4