在线样例

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

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

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

客户端

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

版式说明

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

17 - 商品标价签(绿)

商品标价签(绿)打印样例。

示例代码

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: 378px;
      height: 132px;
      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:2px;top:2px;width:374px;height:128px;box-sizing:border-box;overflow:hidden;border:2px solid #5B9E23;box-sizing:border-box"></div>
<div style="position:absolute;left:100px;top:8px;width:178px;height:18px;box-sizing:border-box;overflow:hidden;font-size:13px;font-weight:700;color:#3F7A16;text-align:center;display:flex;align-items:center;justify-content:center;white-space:pre-wrap">商品标价签</div>
<div style="position:absolute;left:2px;top:30px;width:374px;height:1px;box-sizing:border-box;overflow:hidden;background:#5B9E23"></div>
<div style="position:absolute;left:38px;top:33px;width:150px;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:230px;top:33px;width:140px;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">内蒙古呼和浩特</div>
<div style="position:absolute;left:8px;top:34px;width:26px;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:200px;top:34px;width:26px;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:2px;top:50px;width:374px;height:1px;box-sizing:border-box;overflow:hidden;background:#5B9E23"></div>
<div style="position:absolute;left:168px;top:53px;width:54px;height:14px;box-sizing:border-box;overflow:hidden;font-size:8px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">B-2026-088</div>
<div style="position:absolute;left:258px;top:53px;width:112px;height:14px;box-sizing:border-box;overflow:hidden;font-size:8px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">200g / 杯</div>
<div style="position:absolute;left:8px;top:54px;width:60px;height:12px;box-sizing:border-box;overflow:hidden;font-size:8px;font-weight:700;color:#3F7A16;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">零售价</div>
<div style="position:absolute;left:136px;top:54px;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:230px;top:54px;width:26px;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:8px;top:68px;width:120px;height:50px;box-sizing:border-box;overflow:hidden;background:#FFE100;border:1px solid #5B9E23;box-sizing:border-box"></div>
<div style="position:absolute;left:134px;top:70px;width:240px;height:1px;box-sizing:border-box;overflow:hidden;background:#5B9E23"></div>
<div style="position:absolute;left:12px;top:74px;width:92px;height:30px;box-sizing:border-box;overflow:hidden;font-size:20px;font-weight:700;color:#3F7A16;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">12.80</div>
<div style="position:absolute;left:136px;top:74px;width:50px;height:10px;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:136px;top:84px;width:236px;height:26px;box-sizing:border-box;overflow:hidden;display:flex;flex-direction:column;align-items:center;justify-content:center"><svg width="236" height="24" viewBox="0 0 236 24" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none"><rect x="0" y="0" width="1" height="24" fill="#111"/><rect x="2" y="0" width="1" height="24" fill="#111"/><rect x="5" y="0" width="3" height="24" fill="#111"/><rect x="9" y="0" width="2" height="24" fill="#111"/><rect x="14" y="0" width="1" height="24" fill="#111"/><rect x="17" y="0" width="3" height="24" fill="#111"/><rect x="21" y="0" width="3" height="24" fill="#111"/><rect x="25" y="0" width="1" height="24" fill="#111"/><rect x="27" y="0" width="2" height="24" fill="#111"/><rect x="32" y="0" width="1" height="24" fill="#111"/><rect x="35" y="0" width="3" height="24" fill="#111"/><rect x="39" y="0" width="2" height="24" fill="#111"/><rect x="44" y="0" width="1" height="24" fill="#111"/><rect x="48" y="0" width="1" height="24" fill="#111"/><rect x="50" y="0" width="1" height="24" fill="#111"/><rect x="53" y="0" width="3" height="24" fill="#111"/><rect x="57" y="0" width="2" height="24" fill="#111"/><rect x="62" y="0" width="1" height="24" fill="#111"/><rect x="65" y="0" width="3" height="24" fill="#111"/><rect x="69" y="0" width="3" height="24" fill="#111"/><rect x="73" y="0" width="1" height="24" fill="#111"/><rect x="75" y="0" width="2" height="24" fill="#111"/><rect x="80" y="0" width="1" height="24" fill="#111"/><rect x="83" y="0" width="3" height="24" fill="#111"/><rect x="87" y="0" width="2" height="24" fill="#111"/><rect x="92" y="0" width="1" height="24" fill="#111"/><rect x="96" y="0" width="1" height="24" fill="#111"/><rect x="98" y="0" width="1" height="24" fill="#111"/><rect x="101" y="0" width="3" height="24" fill="#111"/><rect x="105" y="0" width="2" height="2
// …

运行结果

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