在线样例
左侧浏览样例目录,右侧查看版式预览与示例代码;点击运行即可通过 web-print-pdf 驱动本地客户端完成静默打印或 PDF 预览。使用前请先 安装并启动客户端。
客户端
若打印或预览效果与预期不符,请务必先从官网下载并安装最新版 Web打印专家客户端后再试(旧版本可能导致版式偏差)。
版式说明
版式预览与打印输出完全遵循 HTML/CSS 标准样式,没有隐藏的渲染技巧:样式写成什么样,页面就长成什么样。
28 - 外卖打包贴
外卖打包贴打印样例。
版式预览
示例代码
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:22px;box-sizing:border-box;overflow:hidden;background:#C2410C;border:1px solid #C2410C;box-sizing:border-box"></div>
<div style="position:absolute;left:8px;top:3px;width:110px;height:16px;box-sizing:border-box;overflow:hidden;font-size:9px;font-weight:700;color:#FFFFFF;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">已封签 · 请勿开启</div>
<div style="position:absolute;left:140px;top:5px;width:79px;height:12px;box-sizing:border-box;overflow:hidden;font-size:6.5px;color:#FFEDD5;text-align:right;display:flex;align-items:center;justify-content:flex-end;white-space:pre-wrap">10-27 12:08</div>
<div style="position:absolute;left:104px;top:30px;width:40px;height:10px;box-sizing:border-box;overflow:hidden;font-size:6.5px;color:#94A3B8;display:flex;align-items:center;justify-content:flex-start;white-space:pre-wrap">订单号</div>
<div style="position:absolute;left:10px;top:32px;width:84px;height:84px;box-sizing:border-box;overflow:hidden;display:flex;align-items:center;justify-content:center"><svg width="84" height="84" viewBox="0 0 84 84" xmlns="http://www.w3.org/2000/svg"><rect x="0.00" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="22.91" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="38.18" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="68.73" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="76.36" y="0.00" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="30.55" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="45.82" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="68.73" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="76.36" y="7.64" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="38.18" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="53.45" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="68.73" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="76.36" y="15.27" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="22.91" width="7.64" height="7.64" fill="#111"/><rect x="22.91" y="22.91" width="7.64" height="7.64" fill="#111"/><rect x="45.82" y="22.91" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="22.91" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="30.55" width="7.64" height="7.64" fill="#111"/><rect x="30.55" y="30.55" width="7.64" height="7.64" fill="#111"/><rect x="53.45" y="30.55" width="7.64" height="7.64" fill="#111"/><rect x="68.73" y="30.55" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="38.18" width="7.64" height="7.64" fill="#111"/><rect x="22.91" y="38.18" width="7.64" height="7.64" fill="#111"/><rect x="38.18" y="38.18" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="38.18" width="7.64" height="7.64" fill="#111"/><rect x="76.36" y="38.18" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="45.82" width="7.64" height="7.64" fill="#111"/><rect x="30.55" y="45.82" width="7.64" height="7.64" fill="#111"/><rect x="45.82" y="45.82" width="7.64" height="7.64" fill="#111"/><rect x="68.73" y="45.82" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="53.45" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="53.45" width="7.64" height="7.64" fill="#111"/><rect x="38.18" y="53.45" width="7.64" height="7.64" fill="#111"/><rect x="53.45" y="53.45" width="7.64" height="7.64" fill="#111"/><rect x="76.36" y="53.45" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="61.09" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="61.09" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="61.09" width="7.64" height="7.64" fill="#111"/><rect x="22.91" y="61.09" width="7.64" height="7.64" fill="#111"/><rect x="45.82" y="61.09" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="61.09" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="68.73" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="68.73" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="68.73" width="7.64" height="7.64" fill="#111"/><rect x="30.55" y="68.73" width="7.64" height="7.64" fill="#111"/><rect x="53.45" y="68.73" width="7.64" height="7.64" fill="#111"/><rect x="68.73" y="68.73" width="7.64" height="7.64" fill="#111"/><rect x="0.00" y="76.36" width="7.64" height="7.64" fill="#111"/><rect x="7.64" y="76.36" width="7.64" height="7.64" fill="#111"/><rect x="15.27" y="76.36" width="7.64" height="7.64" fill="#111"/><rect x="22.91" y="76.36" width="7.64" height="7.64" fill="#111"/><rect x="38.18" y="76.36" width="7.64" height="7.64" fill="#111"/><rect x="61.09" y="76.36" width="7.64" height="7.64" fill="#111"/><rect x="76.36" y="76.36" width="7.64" height="7.64" fill="#111"/></svg></div>
<div style="position:absolute;left:104px;top:42px;width:115px;height:16px;box-sizing:border-box;
// …
运行结果
- 若无法打印或连接客户端失败,请参阅 本地Print succeeded,上线后无法打印?(HTTP 业务系统上线后常见)。
- 客户端内置「运行示例」页(
vueApp/.../examples/index.vue)提供更多可编辑 demo,与本页样例互补。 - 工具类样例(连接检测、打印机列表等)仅返回 JSON,不触发打印。