在线样例

请启用 JavaScript 后使用在线样例。

您的浏览器版本过旧,请升级至 Chrome、Edge、Firefox 或 Safari 最新版后再访问在线样例。

左侧浏览样例目录,右侧查看版式预览与示例代码;点击运行即可通过 web-print-pdf 驱动本地客户端完成静默打印或 PDF 预览。使用前请先 安装并启动客户端。

客户端

若打印或预览效果与预期不符,请务必先从官网下载并安装最新版 Web打印专家客户端后再试(旧版本可能导致版式偏差)。

版式说明

版式预览与打印输出完全遵循 HTML/CSS 标准样式,没有隐藏的渲染技巧:样式写成什么样,页面就长成什么样。

19 - 生鲜称重标签

生鲜称重标签打印样例。

示例代码

const html = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>生鲜称重标签</title>
  <style>
    html, body { margin: 0; padding: 0; }
    .biz-sheet {
      position: relative;
      width: 227px;
      height: 151px;
      box-sizing: border-box;
      background: #fff;
      font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
      color: #0F172A;
      overflow: hidden;
    }
  </style>
</head>
<body>
  <div class="biz-sheet">
<div style="position:absolute;left:4px;top:4px;width:219px;height:143px;box-sizing:border-box;overflow:hidden;border:1px solid #CBD5E1;box-sizing:border-box"></div>
<div style="position:absolute;left:10px;top:8px;width:130px;height:16px;box-sizing:border-box;overflow:hidden;font-size:11px;font-weight:700;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">悦享生鲜</div>
<div style="position:absolute;left:140px;top:10px;width:78px;height:12px;box-sizing:border-box;overflow:hidden;font-size:7px;color:#64748B;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">2026-10-27 09:32</div>
<div style="position:absolute;left:10px;top:28px;width:207px;height:1px;box-sizing:border-box;overflow:hidden;background:#CBD5E1"></div>
<div style="position:absolute;left:42px;top:31px;width:170px;height:14px;box-sizing:border-box;overflow:hidden;font-size:9px;font-weight:700;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">有机小番茄</div>
<div style="position:absolute;left:10px;top:32px;width:30px;height:12px;box-sizing:border-box;overflow:hidden;font-size:7px;color:#64748B;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">品名</div>
<div style="position:absolute;left:42px;top:49px;width:70px;height:14px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">19.80 元/kg</div>
<div style="position:absolute;left:150px;top:49px;width:68px;height:14px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">0.512 kg</div>
<div style="position:absolute;left:10px;top:50px;width:30px;height:12px;box-sizing:border-box;overflow:hidden;font-size:7px;color:#64748B;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">单价</div>
<div style="position:absolute;left:118px;top:50px;width:30px;height:12px;box-sizing:border-box;overflow:hidden;font-size:7px;color:#64748B;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">净重</div>
<div style="position:absolute;left:10px;top:68px;width:207px;height:1px;box-sizing:border-box;overflow:hidden;background:#CBD5E1"></div>
<div style="position:absolute;left:50px;top:70px;width:96px;height:22px;box-sizing:border-box;overflow:hidden;font-size:15px;font-weight:700;color:#C8102E;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">¥ 10.14</div>
<div style="position:absolute;left:10px;top:72px;width:36px;height:18px;box-sizing:border-box;overflow:hidden;font-size:9px;font-weight:700;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">金额</div>
<div style="position:absolute;left:152px;top:72px;width:58px;height:58px;box-sizing:border-box;overflow:hidden;display:flex;align-items:center;justify-content:center"><svg width="58" height="58" viewBox="0 0 58 58" xmlns="http://www.w3.org/2000/svg"><rect x="0.00" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="5.27" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="10.55" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="15.82" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="26.36" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="42.18" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="47.45" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="52.73" y="0.00" width="5.27" height="5.27" fill="#111"/><rect x="0.00" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="5.27" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="10.55" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="21.09" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="31.64" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="42.18" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="47.45" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="52.73" y="5.27" width="5.27" height="5.27" fill="#111"/><rect x="0.00" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="5.27" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="10.55" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="26.36" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="36.91" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="42.18" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="47.45" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="52.73" y="10.55" width="5.27" height="5.27" fill="#111"/><rect x="5.27" y="15.82" width="5.27" height="5.27" fill="#111"/><rect x="15.82" y="15.82" width="5.27" height="5.27" fill="#111"/><rect x="31.64" y="15.82" width="5.27" height="5.27" fill="#111"/><rect x="42.18" y="15.82" width="5.27" height="5.27" fill="#111"/><rect x="10.55" y="21.09" width="5.27" height="5.27" fill="#111"/><rect x="21.09" y="21.09" width="5.27" height="5.27" fill="#111"/><rect x="36.91" y="21.09" width="5.27" height="5.27" fill="#111"/><rect x="47.45" y="21.09" width="5.27" height="5.27" fill="#111"/><rect x="0.00" y="26.36" width="5.27" height="5.27" fill="#111"/><rect x="15.82" y="26.36" width="5.27" height="5.27" fill="#111"/><rect x="26.36" y="26.36" width="5.27" height="5.27" fill="#111"/><rect x="42.18" y="26.36" width="5.27" height="5.27" fill="#111"/><rect x="52.73" y="26.36" width="5.27" height="5.27" fill="#111"/><rect x="5.27" y="31.64"
// …

运行结果

  • 若无法打印或连接客户端失败,请参阅 本地Print succeeded,上线后无法打印?(HTTP 业务系统上线后常见)。
  • 客户端内置「运行示例」页(vueApp/.../examples/index.vue)提供更多可编辑 demo,与本页样例互补。
  • 工具类样例(连接检测、打印机列表等)仅返回 JSON,不触发打印。
免费下载客户端 查看 npm 包