接入代码(就是这些,全部)
<script src="${ctx}/static/js/hprt-print-sdk.js"></script>
<script>
// 打印:字段名与版式 key 对应,多余的字段自动忽略
PrintSDK.print({
姓名: '张三',
科室: '针灸科',
条码: '20261116001',
二维码: 'http://his.example.com/p/10086',
时间: '2026-11-16 10:30'
}).then(function () {
/* 已下发到打印机 */
}).catch(function (e) {
alert(e.message); // 已是中文可读原因,可直接弹给用户
});
// 停止
PrintSDK.stop();
// 状态
PrintSDK.status().then(function (s) {
// s.normal true/false
// s.text '正常' / '纸用尽、盒盖未到位'
});
</script>
不需要调用 setup,不需要传坐标、尺寸、对齐;标签版式与打印机参数都在 js 文件顶部写好了。