#printing #print #cups #winspool

printers

A lib to get printers and print files on unix and windows

2 stable releases

new 2.1.0 Nov 26, 2024
2.1.0-rc2 Nov 20, 2024
2.0.0 Nov 25, 2023
1.2.0 Feb 9, 2023
1.0.2 Aug 23, 2022

#38 in Windows APIs

Download history 91/week @ 2024-08-11 43/week @ 2024-08-18 17/week @ 2024-08-25 25/week @ 2024-09-01 41/week @ 2024-09-08 92/week @ 2024-09-15 119/week @ 2024-09-22 69/week @ 2024-09-29 122/week @ 2024-10-06 91/week @ 2024-10-13 44/week @ 2024-10-20 93/week @ 2024-10-27 55/week @ 2024-11-03 62/week @ 2024-11-10 312/week @ 2024-11-17 226/week @ 2024-11-24

665 downloads per month

MIT license

45KB
1K SLoC

Printers: A printing APIs implementation for unix (cups) and windows (winspool).

Provides all system printers, create and get print jobs.

Crates.io Version Crates.io License docs.rs Crates.io Downloads (recent)

Documentation

See the references in docs.rs.

Features

Target API List printers List jobs Print bytes and text files Print PDF,images, etc...
Unix cups
Windows winspool 🤔**

** On Windows this lib use RAW datatype to process printing. Expected output depends of printer firmware.

Examples

Get all available printers

let printers = get_printers();
// Vec<Printer>

Create print job of an byte array

printer.print("42".as_bytes());
// Result<(), &'static str>

Create print job of an file

printer.print_file("my_file/example/path.txt");
// Result<(), &'static str>

Get a printer by name

let my_printer = get_printer_by_name("my_printer");
// Option<Printer>

Get the default printer

let printer = get_default_printer();
// Option<Printer>

Simple compilation

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("") or Ok(())
    }

    // 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(())
    }

}

Dependencies