Crate printers

Source
Expand description

Get printers and send files or bytes to print on unix and windows

Printers is a simple lib to call printers apis for unix (cups) and windows (winspool) systems.

Printers can provide a list of printers available on the system and send print jobs to them

use printers::{get_printer_by_name, get_default_printer, get_printers};

fn main() {

   // Iterate all available printers
   for printer in get_printers() {
       println!("{:?}", printer);
   }

   // Get a printer by the name
   let my_printer = get_printer_by_name("my_printer");
   if my_printer.is_some() {
       my_printer.unwrap().print_file("notes.txt", None);
       // Err("cupsPrintFile failed")
   }

   // Use the default printer
   let default_printer = get_default_printer();
   if default_printer.is_some() {
       default_printer.unwrap().print("dlrow olleh".as_bytes(), Some("My Job"));
       // Ok(())
   }

}

Modules§

common

Functions§

get_default_printer
Return the default system printer
get_printer_by_name
If you known the printer nme you can try get the printer directly
get_printers
Return all available printers on system