Print (window.Electron.print)
Native printing and print-to-PDF for the calling window. Source: src/main/print.ts, channel prefix print:*. Always on, no config needed.
Methods
| Method | Returns | Notes |
|---|---|---|
getPrinters() |
Promise<Electron.PrinterInfo[]> |
webContents.getPrintersAsync(). |
print(options?: Electron.WebContentsPrintOptions) |
Promise<{ success: boolean; failureReason?: string }> |
Pass-through to webContents.print(). Resolves (never rejects on print failure) — check success. |
printToPDF(options?: { options?: Electron.PrintToPDFOptions; path?: string }) |
Promise<{ path: string } | { data: string }> |
If path is given, writes the PDF to that path (creating parent directories) and resolves { path }; otherwise resolves { data } — the PDF as base64. |
Example
const printers = await window.Electron.print.getPrinters();
const { success, failureReason } = await window.Electron.print.print({ silent: false });
if (!success) console.error(failureReason);
const { path } = await window.Electron.print.printToPDF({ path: '/tmp/export.pdf' });
.safe
Fully mirrored — window.Electron.safe.print.* resolves { ok: true, data } / { ok: false, error } instead of throwing.