Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows 10 how to? #10

Open
stonewjr opened this issue Oct 12, 2021 · 3 comments
Open

windows 10 how to? #10

stonewjr opened this issue Oct 12, 2021 · 3 comments

Comments

@stonewjr
Copy link

run in windows10
copy testfile "\\LAPTOP-QV366NUQ\Receipt Printer" ok
but run examples\simple.rs no error and printer not things happened?
no error and no message ...

@mdennyh
Copy link

mdennyh commented Apr 30, 2022

The author clearly doesn't provide a working sample to a printer. so here's one:

extern crate escposify;
extern crate tempfile;
use std::fs;
use std::io;

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


fn main() -> io::Result<()> {

    // after you shares your printer, use the following code
    // the IP is the your computer's IP address
    // "Receipt Printer" is the shared name of your printer 
    // (check the control panel -> devices and printer)
    let path = "//192.168.100.8/Receipt Printer";

    // create a file and send it to the printer's path
    // if the path is not available/error you should handle it here.
    let file = File::<fs::File>::from_path(path)?;

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

@yooouuri
Copy link

yooouuri commented Oct 30, 2022

@mdennyh how to do the same for a USB printer for Mac OS?

@mdennyh
Copy link

mdennyh commented Nov 1, 2022

I haven't try to use it in MacOS. But I believe it should be the same. This depends on escposify::device::File; which is a wrapper for std::fs::File. As long as your printer can receive a text file as direct input it should be fine.

But the problem with Apple devices is that it might not be that simple. Apple use bonjour as its print service (https://www.macworld.com/article/189499/macwinprint.html). If you can manage to print from windows to printer on the MacOS, then you can use this package too using the same printer URI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants