7 unstable releases (3 breaking)

0.5.2 Jun 15, 2023
0.5.1 Jun 13, 2023
0.4.1 Jun 10, 2023
0.3.0 Jun 3, 2023
0.1.5 May 30, 2023

#51 in Windows APIs

Download history 44/week @ 2023-06-04 110/week @ 2023-06-11 26/week @ 2023-06-18 18/week @ 2023-06-25 44/week @ 2023-07-02 4/week @ 2023-07-09 9/week @ 2023-07-16 45/week @ 2023-07-23 5/week @ 2023-07-30 44/week @ 2023-08-06 32/week @ 2023-08-13 20/week @ 2023-08-20 31/week @ 2023-08-27 13/week @ 2023-09-03 30/week @ 2023-09-10 26/week @ 2023-09-17

100 downloads per month

MIT license

7MB
1.5K SLoC

TypeScript 565 SLoC // 0.1% comments JavaScript 498 SLoC // 0.1% comments Rust 222 SLoC // 0.2% comments

Contains (DOS exe, 14MB) src/bin/sm

Tauri Plugin Printer

Interface with printers through Powershell

Install

If you are installing from npm and crate.io package registry, make sure the mayor and minor versions for both packages are the same, otherwise, the API may not match.

Crate: https://crates.io/crates/tauri-plugin-printer

Install latest version:

cargo add tauri-plugin-printer

Or add the following to your Cargo.toml for spesific version:

src-tauri/Cargo.toml

[dependencies]
tauri-plugin-printer = { version = "0.5.2" }

You can install the JavaScript Guest bindings using your preferred JavaScript package manager:

pnpm add tauri-plugin-printer
# or
npm add tauri-plugin-printer
# or
yarn add tauri-plugin-printer

Usage

First you need to register the core plugin with Tauri:

src-tauri/src/main.rs

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_printer::init())  
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Afterwards all the plugin's APIs are available through the JavaScript guest bindings:

import {printers, print_file, jobs, job, restart_job, pause_job, resume_job, remove_job} from "tauri-plugin-printer";

// get list printers
const list = await printers()

// get printer by id
const list = await printers(id)

// print pdf file
await print_file({
    id: "idfromlistprinter",
    path: 'F:/path/to/file.pdf', 
    file: BufferData,
    print_setting: {
        orientation: "landscape",
        method: "simplex", // duplex | simplex | duplexshort
        paper: "A4", // "A2" | "A3" | "A4" | "A5" | "A6" | "letter" | "legal" | "tabloid"
        scale: "noscale", //"noscale" | "shrink" | "fit"
        repeat: 1 // "noscale" | "shrink" | "fit"
    }
})

// get all printer jobs
await jobs()

// get printer jobs by printer id 
await jobs(idprinter)

// get job by id
await job(id)

// restart all job
await restart_job()

// restart job by id
await restart_job(id)

// pause all job
await pause_job()

// pause job by id
await pause_job(id)

// resume all job 
await resume_job()

// resume job by id
await resume_job(id)

// remove all job
await remove_job()

// resume job by id
await remove_job(id)

Donate

PayPal

Saweria

License

Code: (c) 2023 - Present Alfian Lensun.

MIT where applicable.

Dependencies

~18–70MB
~1M SLoC