print.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. document.addEventListener( "plusready", function()
  2. {
  3. var _BARCODE = 'BluetoothPrinter',
  4. B = window.plus.bridge;
  5. var BluetoothPrinter =
  6. {
  7. PrintSync : function (Argus)
  8. {
  9. return B.execSync(_BARCODE, "PrintSync", [Argus]);
  10. }
  11. };
  12. window.plus.BluetoothPrinter = BluetoothPrinter;
  13. }, true );
  14. function printTest()
  15. {
  16. var DATA =
  17. "{"
  18. +"'paperHeight':30.0,"
  19. +"'paperWidth':100.0,"
  20. +"'paperMargin' : 2,"
  21. +"'printItems' : ["
  22. +"{"
  23. +"'content':'测试文本',"
  24. +"'enabled':true,"
  25. +"'displayType':'文本',"
  26. +"'left':5.0,"
  27. +"'top':5.0,"
  28. +"'width':40.0,"
  29. +"'height':4.0"
  30. +"},"
  31. +"{"
  32. +"'content':'123456',"
  33. +"'enabled':true,"
  34. +"'displayType':'条形码',"
  35. +"'left':5.0,"
  36. +"'top':10.0,"
  37. +"'width':30.0,"
  38. +"'height':5.0"
  39. +"},"
  40. +"{"
  41. +"'content':'123456789012345678901236',"
  42. +"'enabled':false,"
  43. +"'displayType':'二维码',"
  44. +"'left':5.0,"
  45. +"'top':18.0,"
  46. +"'width':10.0,"
  47. +"'height':7.0"
  48. +"},"
  49. +"{"
  50. +"'content':'123456789012345678901233',"
  51. +"'displayType':'EPC',"
  52. +"'enabled':true,"
  53. +"'left':0,"
  54. +"'top':0,"
  55. +"'width':0,"
  56. +"'height':0"
  57. +"}"
  58. +"]"
  59. +"}";
  60. alert(DATA);
  61. var Argus = plus.BluetoothPrinter.PrintSync(DATA);
  62. }