printHtml API reference & best practices

printHtml renders HTML to PDF and prints via the local client—the primary web-print-pdf entry point.

Signature

printHtml(html, pdfOptions?, printOptions?, extraOptions?): Promise<PrintResult>

Parameters

ArgStageGuide
htmlInput stringdemos
pdfOptionsLayout → PDFprint options
printOptionsPDF → printerprint options
extraOptionspreview, timeoutprint options

Minimal example

import webPrintPdf from 'web-print-pdf';

await webPrintPdf.printHtml('<p>Hello</p>', {}, { copies: 1 });

When to use

  • You already have HTML reports
  • Need silent named printer
  • Trigger from UI events

Read next

FAQ

Client must be running?

Yes—use getConnectStatus; see error-handling.

Same-named pdf/print fields?

Configure in pairs—especially paper size.

Preview only?

extraOptions.action = "preview".

Call from SSR?

Browser/client components only.

vs printHtmlByUrl?

ByUrl fetches a URL; printHtml takes HTML string.

Client deployment by platform

The same web-print-pdf front-end runs on Windows, macOS, and Linux/domestic OS—install the matching client on each desktop.

Download client — free trial View npm package Documentation