https://github.com/don/posify
A ESC/POS (snbc specific) driver in Rust
https://github.com/don/posify
Last synced: 7 months ago
JSON representation
A ESC/POS (snbc specific) driver in Rust
- Host: GitHub
- URL: https://github.com/don/posify
- Owner: don
- License: mit
- Created: 2023-08-23T14:18:10.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T20:56:53.000Z (about 2 years ago)
- Last Synced: 2025-02-23T16:13:14.247Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 178 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# escposify-rs
A ESC/POS driver for Rust
[Documentation](https://docs.rs/escposify)
Most ESC/POS Printers will appear as a file. To print to the device, open a file to the location and pass this to the ```File::from``` function.
# Examples
## Rust
See: [simple.rs](examples/fromlp0.rs)
Note: You can run examples with `cargo run --example fromlp0`.
``` rust
use std::fs::OpenOptions;
use std::io;
use posify::printer::{BarcodeType, Font, Printer, SupportedPrinters, TextPosition};
fn main() -> io::Result<()> {
let device_file = OpenOptions::new()
.read(true)
.write(true)
.open("/dev/usb/lp0").unwrap();
let mut printer = Printer::new(device_file, None, None, SupportedPrinters::P3);
printer
.chain_hwinit()?
.chain_align("ct")?
.chain_underline_mode(Some("thick"))?
.chain_text("Underlined Text")?
.chain_underline_mode(Some("off"))?
.chain_text("The quick brown fox jumps over the lazy dog")?
.chain_feed(1)?
.chain_barcode("0123456789023",
BarcodeType::Code128,
TextPosition::Below,
Font::FontA,
2,
0x40)?
.chain_feed(1)?
.chain_partial_cut()?
.flush()
}
```