printData

2022-07-01 11:58 更新

打印數(shù)據(jù)

printData({params}, callback(ret, err))

params

  • data:

  • 類型:數(shù)組
  • 描述:打印數(shù)據(jù)。

  1. [{
  2. rowtype: 'printText', //打印文字,文字寬度滿一行自動換行排版
  3. text : '', //要打印的文字字符串
  4. size:, //字體大小
  5. isBole:'', //粗體
  6. isUnderLine:'', //下劃線
  7. },{
  8. rowtype: 'lineWrap', //打印機走紙
  9. n : 3 //走紙行數(shù)
  10. },{
  11. rowtype: 'printTable', //打印表格
  12. colsText : "名稱,數(shù)量,單價,金額", //表頭
  13. colsWidth:[10, 6, 6, 8], //各列單元格寬度
  14. colsAlign:[1, 2, 2, 2], //各列單元格對齊(0居左, 1居中, 2居右)
  15. dataArr:[ //單元內(nèi)容(數(shù)組)
  16. "商品A,6,12.00,72.00",
  17. "商品B,8,13.00,104.00"],
  18. },{
  19. rowtype : "setFontSize", //設(shè)置字體大小, 對之后打印有影響,除非初始化
  20. size:24 //字體大小
  21. },{
  22. rowtype : "setAlignment", //設(shè)置對齊模式,對之后打印有影響,除非初始化
  23. alignment:1 //對齊方式 0--居左 , 1--居中, 2--居右
  24. },{
  25. rowtype : 'printBitmap', //打印圖片
  26. image:'widget://res/test.jpg' //圖片bitmap對象(最大寬度384像素,超過無法打印) 支持widget:// fs://
  27. },{
  28. rowtype: 'printBarCode', //打印條形碼
  29. text : '', //條碼數(shù)據(jù)
  30. symbology : 8, //條碼類型:0:UPC-A,1:UPC-E,2:JAN13(EAN13),3:JAN8(EAN8),4:CODE39,5:ITF,6:CODABAR,7:CODE93,8:CODE128
  31. height : 80, //條碼高度:取值1到255, 默認162
  32. width : 2, //條碼寬度:取值2至6, 默認2
  33. textposition : 2 //文字位置:0--不打印文字, 1--文字在條碼上方, 2--文字在條碼下方, 3--條碼上下方均打印
  34. }]

callback(ret, err)

ret:

  • 類型:JSON 對象
  • 內(nèi)部字段:

  1. {
  2. status: true //布爾型;true||false
  3. }

err:

  • 類型:JSON對象
  • 內(nèi)部字段:

  1. {
  2. msg: ''
  3. }

示例代碼

  1. var param = {data:[
  2. {
  3. rowtype : 'printText',
  4. text:'Hello APICloud!',
  5. size:18,
  6. isBole:'false',
  7. isUnderLine:'fasle'
  8. },{
  9. rowtype : 'lineWrap',
  10. n:1
  11. },{
  12. rowtype : 'printTable',
  13. colsText:"名稱,數(shù)量,單價,金額",
  14. colsWidth : [10, 6, 6, 8],
  15. colsAlign : [1, 2, 2, 2],
  16. dataArr:[
  17. "商品A,6,12.00,72.00",
  18. "商品B,8,13.00,104.00"],
  19. },{
  20. rowtype : 'printText',
  21. text:'------------------'
  22. },{
  23. rowtype : "setFontSize",
  24. size:24
  25. },{
  26. rowtype : "setAlignment",
  27. alignment:1
  28. },{
  29. rowtype : 'printText',
  30. text:'Hello APICloud!',
  31. },{
  32. rowtype : 'printBitmap',
  33. image:'widget://res/test.jpg'
  34. },{
  35. rowtype : 'printBarCode',
  36. text:'20190630001',
  37. symbology:8,
  38. height:80,
  39. width:2,
  40. textposition:2
  41. },{
  42. rowtype : 'lineWrap',
  43. n:3
  44. }
  45. ]};
  46. sunmiV2Printer.printData(param,function(ret, err){
  47. alert(JSON.stringify(ret));
  48. });

可用性

Android系統(tǒng)

可提供的1.0.0及更高版本

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號