1.传入模板json 设置条码打印模板
hiprint.init(); hiprintTemplate = new hiprint.PrintTemplate({ template: JSON.parse($('#barcodeJson1').val()), settingContainer: '#PrintElementOptionSetting' });
2.通过调用函数方式实现设置条码打印模板
<!-- 创建打印模板对象--> var hiprintTemplate = new hiprint.PrintTemplate(); <!-- 模板对象添加打印面板 paperHeader:页眉线 paperFooter:页尾线--> var panel = hiprintTemplate.addPrintPanel({ width: 50, height: 30, paperNumberDisabled: true }); <!-- 文本 打印面板添加文本元素--> panel.addPrintText({ options: { "left": 7.5, "top": 9, "height": 15, "width": 127.5, "field": "product", "testData": "加多老吉茶 100889", "hideTitle": true } }); <!-- 文本 打印面板添加文本元素--> panel.addPrintText({ options: { "left": 120, "top": 27, "height": 33, "width": 13.5, "field": "ptype", "testData": "酒水", "hideTitle": true } }); <!-- 条形码 打印面板添加二维码元素--> panel.addPrintText({ options: { "left": 7.5, "top": 28.5, "height": 30, "width": 105, "field": "code", "testData": "100889", "textAlign": "center", "textType": "barcode" } }); <!-- 打印设计--> hiprintTemplate2.design('#hiprint-printTemplate2');