Live demos
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.
20 - Base64 PDF
printPdfByBase64 prints server-encoded PDF payloads without a download URL.
Layout preview
Sample code
// 业务中通常由服务端直接返回 PDF Base64;此处从演示地址拉取并编码
const res = await fetch('https://webprintpdf.com/api/fileCenter/webPrintExpert/fileCenterFileDownload/printTest.pdf');
const bytes = new Uint8Array(await res.arrayBuffer());
let binary = '';
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
const pdfBase64 = btoa(binary);
await webPrintPdf.printPdfByBase64(
pdfBase64,
{ paperFormat: 'A4' },
{ paperFormat: 'A4', copies: 1 }
);
Result
- Demos load bundled
web-print-pdffirst (same API as npm); CDN is used as fallback. - 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.