GithubHelp home page GithubHelp logo

laven11 / rust-escposify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from local-group/rust-escposify

0.0 0.0 0.0 84 KB

A ESC/POS driver in Rust ( Documentation: https://docs.rs/escposify )

License: MIT License

JavaScript 2.89% Rust 96.13% Makefile 0.98%

rust-escposify's Introduction

escposify-rs

A ESC/POS driver for Rust

Documentation

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.

To enable this in Windows, install the printer and its driver. Share the printer and specifiy a name for it (Receipt Printer in this case). The printer will then be accessable via \\%COMPUTERNAME%\Receipt Printer. To test this in the command line:

echo "Hello World" > testfile
copy testfile "\\%COMPUTERNAME%\Receipt Printer"
del testfile

Examples

Rust

See: simple.rs

extern crate escposify;
extern crate tempfile;

use std::io;

use escposify::device::File;
use escposify::printer::Printer;

use tempfile::NamedTempFileOptions;

fn main() -> io::Result<()> {
    let tempf = NamedTempFileOptions::new().create().unwrap();

    let file = File::from(tempf);
    let mut printer = Printer::new(file, None, None);

    printer
        .chain_font("C")?
        .chain_align("lt")?
        .chain_style("bu")?
        .chain_size(0, 0)?
        .chain_text("The quick brown fox jumps over the lazy dog")?
        .chain_text("敏捷的棕色狐狸跳过懒狗")?
        .chain_barcode("12345678", "EAN8", "", "", 0, 0)?
        .chain_feed(1)?
        .chain_cut(false)?
        .flush()
}

rust-escposify's People

Contributors

hgrahamcs avatar jstsddg avatar kinnison avatar masterchef365 avatar thewawar avatar tl8roy 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.