Live demos

Enable JavaScript to use the live demos.

Your browser is too old for this page. Please use the latest Chrome, Edge, Firefox, or Safari.

Browse the sample list on the left and preview layouts plus sample code on the right. Run a demo to print silently or preview PDF via web-print-pdf and the local client. Install and launch the client first.

Client

If results look wrong, install the latest Web Print Expert client from our site first (older builds may cause layout drift).

Layout

Preview and print follow standard HTML/CSS only—no hidden tricks. What you style is what you get.

07 - 80mm demo receipt

pdf uses width + height (80mm×80mm). Set html, body { margin: 0; padding: 0; } in HTML (see receiptHtml below) to avoid extra pages from default body margin. Set printOptions.paperFormat from getPrinterPapers for real printing. Thermal printers: set sharp: true for anti-alias.

Sample code

const receiptWidth = '80mm';
const receiptHeight = '80mm';

const receiptHtml = `<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <style>
    html, body { margin: 0; padding: 0; }
    .receipt {
      width: ${receiptWidth};
      box-sizing: border-box;
      font-family: monospace;
      padding: 4mm;
      font-size: 11px;
      line-height: 1.45;
    }
  </style>
</head>
<body>
  <div class="receipt">
  <div style="text-align:center;font-size:10px;color:#666;margin-bottom:4px">【演示小票 · 非真实交易】</div>
  <div style="text-align:center;font-size:14px;font-weight:bold;margin-bottom:6px">溪边良品小铺(虚构)</div>
  <div style="text-align:center;margin-bottom:8px">杭州市拱墅区运河畔路 18 号</div>
  <div>演示单号:WP-POS-240624-1024</div>
  <div>打印时间:2026-06-24 14:32:08</div>
  <div style="border-top:1px dashed #333;margin:8px 0;padding-top:6px">
    燕麦拿铁 400ml ×1 .... ¥22.00<br>
    全麦三明治 ×1 ........ ¥15.00<br>
    蓝莓司康 ×2 .......... ¥18.00
  </div>
  <div style="border-top:1px dashed #333;margin-top:8px;padding-top:6px;font-weight:bold">
    演示合计:¥55.00<br>支付方式:演示扫码
  </div>
  <div style="text-align:center;margin-top:10px;font-size:10px">web-print-pdf 热敏纸版式演示</div>
  </div>
</body>
</html>`;

await webPrintPdf.printHtml(receiptHtml, {
  width: receiptWidth,
  height: receiptHeight,
  margin: { top: '2mm', bottom: '2mm', left: '2mm', right: '2mm' },
  printBackground: true
}, {
  // 实际打印时,须指定当前打印机上支持此尺寸的纸张名称(名称以 getPrinterPapers 返回为准),如果指定的纸张不符合此尺寸,效果是不对的。也可以不传递此参数,而是通过在当前软件打印机这个栏目的操作列,预先设置好 “打印首选纸张” 这个弹窗里的参数达到同样的效果
  paperFormat: '80mm Series',
  sharp: true /* 如果是热敏打印机,开启 sharp 抗锯齿,否则 false 即可 */
});

Result

  • If printing fails or the client cannot connect, see Local print works—production does not? (common on HTTP deployments).
  • The client’s built-in Run examples page has more editable demos; this page complements it.
  • Utility demos (connection, printer list) return JSON only—no print job.
Download client free View npm package