📊 Real-time monitoring - Printer state changes and job tracking
🔧 Flexible options - Simple, CUPS, and raw printing configuration
⚡ Async control - Choose immediate return or wait for completion
macOS: x64, arm64
Windows: x64, arm64
Linux (glibc only): x64, arm64
npm install @printers/printers
Note
This package exposes a Node-API addon for running the Rust backend natively. To use Node-API addons in Deno, you must enable nodeModulesDir in your deno.json configuration file and pass the --allow-ffi flag when running your program. To learn more, see the Node and npm compatibility and Security and permissions documentation.
import{getAllPrinters,getPrinterByName}from"@printers/printers";// List all available printersconstprinters=getAllPrinters();console.log("Available printers:",printers.map(p=>p.name));// Print a documentconstprinter=getPrinterByName("My Printer");if(printer){constjobId=awaitprinter.printFile("document.pdf",{simple: {copies: 2,duplex: true,quality: "high",},});console.log("Print job submitted:",jobId);}
getAllPrinters(): Printer[]
Returns an array of all available system printers.
getPrinterByName(name: string): Printer | null
Find a printer by its exact name.
getAllPrinterNames(): string[]
Returns an array of printer names.
printerExists(name: string): boolean
Check if a printer exists on the system.
name: string - Printer display name
state?: PrinterState - Current printer state ("idle", "printing", "paused", "offline", "unknown")
isDefault?: boolean - Whether this is the default printer
location?: string - Physical location description
driverName?: string - Printer driver name
stateReasons?: string[] - Array of state reason strings
printFile(filePath: string, options?: PrintJobOptions): Promise<number> - Print a file and return job ID
printBytes(data: Uint8Array, options?: PrintJobOptions): Promise<number> - Print raw bytes and return job ID
getActiveJobs(): PrinterJob[] - Get currently active/pending jobs
getJobHistory(limit?: number): PrinterJob[] - Get completed job history
getJob(jobId: number): PrinterJob | null - Get specific job details
cleanupOldJobs(maxAgeSeconds: number): number - Remove old jobs
Start printer state monitoring with optional configuration.
interfacePrintJobOptions{jobName?: string;// Job name for identificationwaitForCompletion?: boolean;// Wait for completion (default: true)simple?: SimplePrintOptions;// Easy-to-use optionscups?: CUPSOptions;// Full CUPS optionsraw?: Record<string,string>;// Raw key-value options}