在线样例

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

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

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

客户端

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

版式说明

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

48 - 员工工牌

员工工牌打印样例。

示例代码

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: 204px;
      height: 325px;
      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:6px;top:6px;width:192px;height:313px;box-sizing:border-box;overflow:hidden;border:1px solid #CBD5E1;box-sizing:border-box"></div>
<div style="position:absolute;left:6px;top:6px;width:192px;height:54px;box-sizing:border-box;overflow:hidden;background:#F1F5F9"></div>
<div style="position:absolute;left:16px;top:18px;width:172px;height:28px;box-sizing:border-box;overflow:hidden;font-size:11px;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:52px;top:74px;width:100px;height:110px;box-sizing:border-box;overflow:hidden;background:#F8FAFC;border:1px dashed #E2E8F0;box-sizing:border-box"></div>
<div style="position:absolute;left:52px;top:122px;width:100px;height:16px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#94A3B8;text-align:center;display:flex;align-items:center;justify-content:center;white-space:pre-wrap">照片</div>
<div style="position:absolute;left:16px;top:196px;width:172px;height:30px;box-sizing:border-box;overflow:hidden;font-size:20px;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:30px;top:238px;width:36px;height:16px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#64748B;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">部门</div>
<div style="position:absolute;left:68px;top:238px;width:106px;height:16px;box-sizing:border-box;overflow:hidden;font-size:10px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">产品设计部</div>
<div style="position:absolute;left:30px;top:258px;width:36px;height:16px;box-sizing:border-box;overflow:hidden;font-size:9px;color:#64748B;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">工号</div>
<div style="position:absolute;left:68px;top:258px;width:106px;height:16px;box-sizing:border-box;overflow:hidden;font-size:10px;color:#0F172A;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">PD-2026-018</div>
<div style="position:absolute;left:84px;top:278px;width:36px;height:36px;box-sizing:border-box;overflow:hidden;display:flex;align-items:center;justify-content:center"><svg width="36" height="36" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg"><rect x="0.00" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="3.27" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="6.55" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="9.82" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="16.36" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="26.18" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="29.45" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="32.73" y="0.00" width="3.27" height="3.27" fill="#111"/><rect x="0.00" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="3.27" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="6.55" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="13.09" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="19.64" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="26.18" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="29.45" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="32.73" y="3.27" width="3.27" height="3.27" fill="#111"/><rect x="0.00" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="3.27" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="6.55" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="16.36" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="22.91" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="26.18" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="29.45" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="32.73" y="6.55" width="3.27" height="3.27" fill="#111"/><rect x="3.27" y="9.82" width="3.27" height="3.27" fill="#111"/><rect x="9.82" y="9.82" width="3.27" height="3.27" fill="#111"/><rect x="19.64" y="9.82" width="3.27" height="3.27" fill="#111"/><rect x="26.18" y="9.82" width="3.27" height="3.27" fill="#111"/><rect x="6.55" y="13.09" width="3.27" height="3.27" fill="#111"/><rect x="13.09" y="13.09" width="3.27" height="3.27" fill="#111"/><rect x="22.91" y="13.09" width="3.27" height="3.27" fill="#111"/><rect x="29.45" y="13.09" width="3.27" height="3.27" fill="#111"/><rect x="0.00" y="16.36" width="3.27" height="3.27" fill="#111"/><rect x="9.82" y="16.36" width="3.27" height="3.27" fill="#111"/><rect x="16.36" y="16.36" width="3.27" height="3.27" fill="#111"/><rect x="26.18" y="16.36" width="3.27" height="3.27" fill="#111"/><rect x="32.73" y="16.36" width="3.27" height="3.27" fill="#111"/><rect x="3.27" y="19.64" width="3.27" height="3.27" fill="#111"/><rect x="13.09" y="19.64" width="3.27" height="3.27" fill="#111"/><rect x="19.64" y="19.64" width="3.27" height="3.27" fill="#111"/><rect x="29.45" y="19.64" width="3.27" height="3.27" fill="#111"/><rect x="0.00" y="22.91" width="3.27" height="3.27" fill="#111"/><rect x="6.55" y="22.91" width="3.27" height="3.27" fill="#111"/><rect x="16.36" y="22.91" width="3.27" height="3.27" fill="#111"/><rect x="22.91" y="22.91" width="3.27" height="3.27" fill="#111"/><rect x="32.73" y="22.91" width="3.27" height="3.27" fill="#111"/><rect x="0.00" y="26.18" width="3.27" height="3.27" fill="#111"/><rect x="3.27" y="26.18" width="3.27"
// …

运行结果

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