Giter Site home page Giter Site logo

rust-printers's Introduction

Printers

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

Printer can provide a list of printers available on the system and perform document printing.

Behavior

Return a vector of available printers

printers::get_printers() -> Vec<Printer>

Request print of a temp file after write they

printers::print(Printer, &[u8]) -> Job
printer.print(&[u8]) -> Job

Request print of specific file from path

printers::print_file(Printer, &str) -> Job
printer.print_file(&str) -> Job

Try get and return a single printer by your name

printers::get_printer_by_name(&str) -> Option<Printer>

NOTE: get_printer_by_name is a simple utility, this functions just apply filters over call get_printers() result. They are improved on future to be more performatic

Example

use printers;

fn main() {


    // Vector of system printers
    let printers = printers::get_printers();

    // Print directly in all printers
    for printer in printers.clone() {

        println!("{:?}", printer);

        let status1 = printer.print("42".as_bytes(), Some("Everything"));
        println!("{:?}", status1);
        
        // Note: When you don't give the job_name
        // the file path will be that name by default
        let status2 = printer.print_file("/path/to/any.file", None);
        println!("{:?}", status2);

    }

    // Print directly by printer name
    printers::print("printer-a", "42".as_bytes(), Some("Everything"));
    printers::print_file("printer-b", "/path/to/any.file", Some("My Job"));

    // Try printer by name
    let test_printer = printers::get_printer_by_name("test");
    println!("{:?}", test_printer);

}

System Requiriments

Windows

For Windows printers will be use winspool apis to retrive printer and powershell to send a doc to printer

Note: For some complex reasons, the printing action stays doing using powershell. If you want collaborate to implement winspool for printing documents, your contribution will be greatly appreciated

Unix

For Unix is necessary cups service installed

rust-printers's People

Contributors

talesluna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.