在线样例

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

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

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

客户端

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

版式说明

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

27 - 散装称重标

散装称重标打印样例。

示例代码

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:0px;top:0px;width:227px;height:38px;box-sizing:border-box;overflow:hidden;background:#B45309;border:1px solid #B45309;box-sizing:border-box"></div>
<div style="position:absolute;left:10px;top:8px;width:116px;height:22px;box-sizing:border-box;overflow:hidden;font-size:13px;font-weight:700;color:#FFFFFF;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">东北五常大米</div>
<div style="position:absolute;left:132px;top:8px;width:84px;height:18px;box-sizing:border-box;overflow:hidden;font-size:8px;color:#FDE68A;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">6.80 元/kg</div>
<div style="position:absolute;left:132px;top:28px;width:84px;height:8px;box-sizing:border-box;overflow:hidden;font-size:5.5px;color:#FDE68A;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">单价</div>
<div style="position:absolute;left:14px;top:46px;width:80px;height:12px;box-sizing:border-box;overflow:hidden;font-size:7px;color:#92400E;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">净重</div>
<div style="position:absolute;left:122px;top:46px;width:91px;height:12px;box-sizing:border-box;overflow:hidden;font-size:7px;color:#92400E;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">金额</div>
<div style="position:absolute;left:14px;top:60px;width:90px;height:30px;box-sizing:border-box;overflow:hidden;font-size:22px;font-weight:700;color:#78350F;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">2.350</div>
<div style="position:absolute;left:122px;top:60px;width:91px;height:30px;box-sizing:border-box;overflow:hidden;font-size:22px;font-weight:700;color:#C2410C;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">15.98</div>
<div style="position:absolute;left:14px;top:92px;width:90px;height:12px;box-sizing:border-box;overflow:hidden;font-size:8px;color:#92400E;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">kg</div>
<div style="position:absolute;left:122px;top:92px;width:91px;height:12px;box-sizing:border-box;overflow:hidden;font-size:8px;color:#92400E;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">元</div>
<div style="position:absolute;left:10px;top:104px;width:207px;height:1px;box-sizing:border-box;overflow:hidden;background:#E7C9A6"></div>
<div style="position:absolute;left:10px;top:106px;width:207px;height:30px;box-sizing:border-box;overflow:hidden;display:flex;flex-direction:column;align-items:center;justify-content:center"><svg width="207" height="17" viewBox="0 0 207 17" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none"><rect x="0" y="0" width="1" height="17" fill="#111"/><rect x="2" y="0" width="3" height="17" fill="#111"/><rect x="7" y="0" width="3" height="17" fill="#111"/><rect x="11" y="0" width="2" height="17" fill="#111"/><rect x="16" y="0" width="1" height="17" fill="#111"/><rect x="19" y="0" width="3" height="17" fill="#111"/><rect x="23" y="0" width="1" height="17" fill="#111"/><rect x="25" y="0" width="1" height="17" fill="#111"/><rect x="29" y="0" width="2" height="17" fill="#111"/><rect x="34" y="0" width="1" height="17" fill="#111"/><rect x="37" y="0" width="3" height="17" fill="#111"/><rect x="41" y="0" width="2" height="17" fill="#111"/><rect x="46" y="0" width="1" height="17" fill="#111"/><rect x="48" y="0" width="1" height="17" fill="#111"/><rect x="50" y="0" width="3" height="17" fill="#111"/><rect x="55" y="0" width="3" height="17" fill="#111"/><rect x="59" y="0" width="2" height="17" fill="#111"/><rect x="64" y="0" width="1" height="17" fill="#111"/><rect x="67" y="0" width="3" height="17" fill="#111"/><rect x="71" y="0" width="1" height="17" fill="#111"/><rect x="73" y="0" width="1" height="17" fill="#111"/><rect x="77" y="0" width="2" height="17" fill="#111"/><rect x="82" y="0" width="1" height="17" fill="#111"/><rect x="85" y="0" width="3" height="17" fill="#111"/><rect x="89" y="0" width="2" height="17" fill="#111"/><rect x="94" y="0" width="1" height="17" fill="#111"/><rect x="96" y="0" width="1" height="17" fill="#111"/><rect x="98" y="0" width="3" height="17" fill="#111"/><rect x="103" y="0" width="3" height="17" fill="#111"/><rect x="107" y="0" width="2" height="17" fill="#111"/><rect x="112" y="0" width="1" height="17" fill="#111"/><rect x="115" y="0" width="3" height="17" fill="#111"/><rect x="119" y="0" width="1" height="17" fill="#111"/><rect x="121" y="0" width="1" height="17" fill="#111"/><rect x="125" y="0" width="2" height="17" fill="#111"/><rect x="130" y="0" width="1" height="17" fill="#111"/><rect x="133" y="0" width="3" height="17" fill="#111"/><rect x="137" y="0" width="2" height="17" fill="#111"/><rect x="142" y="0" width="1" height="17" fill="#111"/><rect x="144" y="0" width="1" height="17" fill="#111"/><rect x="146" y="0" width="3" height="17" fill="#111"/><rect x="151" y="0" width="3" height="17" fill="#111"/><rect x="155" y="0" width="2" height="17" fill="#111"/><rect x="160" y="0" width="1" height="17" fill="#111"/><rect x="163" y="0" width="3" height="17" fill="#111"/><rect x="167" y="0" width="1" height="17" fill="#111"/><rect x="169" y="0" width="1" height="17" fill="#111"/><rect x="173" y="0" width="2" height="17" fill="#111"/><rect x="178" y="0" width="1" height="17" fill="#111"/><rect x="181" y="0" width="3" height="17" fill="#1
// …

运行结果

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