在线样例

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

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

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

客户端

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

版式说明

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

55 - 资产标签

资产标签打印样例。

示例代码

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:3px;top:3px;width:221px;height:145px;box-sizing:border-box;overflow:hidden;border:1px solid #1D4ED8;box-sizing:border-box"></div>
<div style="position:absolute;left:8px;top:8px;width:211px;height:18px;box-sizing:border-box;overflow:hidden;font-size:12px;font-weight:700;color:#0F172A;text-align:center;display:flex;align-items:center;justify-content:center;white-space:pre-wrap">固定资产标签</div>
<div style="position:absolute;left:3px;top:30px;width:221px;height:1px;box-sizing:border-box;overflow:hidden;background:#1D4ED8"></div>
<div style="position:absolute;left:52px;top:33px;width:111px;height:16px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">ThinkPad X1</div>
<div style="position:absolute;left:8px;top:34px;width:42px;height:14px;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:52px;top:55px;width:111px;height:16px;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:56px;width:42px;height:14px;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:52px;top:77px;width:111px;height:16px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">3F 设计部 A-12</div>
<div style="position:absolute;left:8px;top:78px;width:42px;height:14px;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:107px;width:211px;height:34px;box-sizing:border-box;overflow:hidden;display:flex;flex-direction:column;align-items:center;justify-content:center"><svg width="211" height="24" viewBox="0 0 211 24" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none"><rect x="0" y="0" width="1" height="24" fill="#111"/><rect x="3" y="0" width="3" height="24" fill="#111"/><rect x="7" y="0" width="3" height="24" fill="#111"/><rect x="11" y="0" width="1" height="24" fill="#111"/><rect x="13" y="0" width="1" height="24" fill="#111"/><rect x="16" y="0" width="3" height="24" fill="#111"/><rect x="20" y="0" width="1" height="24" fill="#111"/><rect x="23" y="0" width="3" height="24" fill="#111"/><rect x="27" y="0" width="3" height="24" fill="#111"/><rect x="31" y="0" width="1" height="24" fill="#111"/><rect x="33" y="0" width="1" height="24" fill="#111"/><rect x="36" y="0" width="3" height="24" fill="#111"/><rect x="40" y="0" width="1" height="24" fill="#111"/><rect x="43" y="0" width="3" height="24" fill="#111"/><rect x="47" y="0" width="3" height="24" fill="#111"/><rect x="51" y="0" width="1" height="24" fill="#111"/><rect x="53" y="0" width="1" height="24" fill="#111"/><rect x="56" y="0" width="3" height="24" fill="#111"/><rect x="60" y="0" width="1" height="24" fill="#111"/><rect x="63" y="0" width="3" height="24" fill="#111"/><rect x="67" y="0" width="3" height="24" fill="#111"/><rect x="71" y="0" width="1" height="24" fill="#111"/><rect x="73" y="0" width="1" height="24" fill="#111"/><rect x="76" y="0" width="3" 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="3" height="24" fill="#111"/><rect x="91" y="0" width="1" height="24" fill="#111"/><rect x="93" y="0" width="1" height="24" fill="#111"/><rect x="96" y="0" width="3" height="24" fill="#111"/><rect x="100" y="0" width="1" height="24" fill="#111"/><rect x="103" y="0" width="3" height="24" fill="#111"/><rect x="107" y="0" width="3" height="24" fill="#111"/><rect x="111" y="0" width="1" height="24" fill="#111"/><rect x="113" y="0" width="1" height="24" fill="#111"/><rect x="116" y="0" width="3" height="24" fill="#111"/><rect x="120" y="0" width="1" height="24" fill="#111"/><rect x="123" y="0" width="3" height="24" fill="#111"/><rect x="127" y="0" width="3" height="24" fill="#111"/><rect x="131" y="0" width="1" height="24" fill="#111"/><rect x="133" y="0" width="1" height="24" fill="#111"/><rect x="136" y="0" width="3" height="24" fill="#111"/><rect x="140" y="0" width="1" height="24" fill="#111"/><rect x="143" y="0" width="3" height="24" fill="#111"/><rect x="147" y="0" width="3" height="24" fill="#111"/><rect x="151" y="0" width="1" height="24" fill="#111"/><rect x="153" y="0" width="1" height="24" fill="#111"/><rect x="156" y="0" width="3" height="24" fill="#111"/><rect x="160" y="0" width="1" height="24" fill="#111"/><rect x="163" y="0" width="3" height="24" fill="#111"/><rect x="167" y="0" width="3" height="24" fill="#111"/><rect x="171" y="0" width="1" height="24" fill="#111"/><rect x="173" y="0" width="1" height="24" fill="#111"/><rect x="176" y="0" width="3" height="24" fill="#111"/><rect x="180" y="0" width="1" height="24" fill="#111"/><rect x="183" y="0" width="3" height="24" fill="#111"/><rect x="187" y="0" width="3" height="24" fill="#111"/><rect x="191" y="0" width="1" height="24" fill="#111"/><rect x="193" y="0" width="1" height="24" fill="#111"/><rect x="196" y="0" width="3" height="24" fill="#111"/><rect x="200" y="0
// …

运行结果

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