talesluna / rust-printers Goto Github PK
View Code? Open in Web Editor NEWA rust library to list printers and print files on windows and unix (winspool/cups)
License: MIT License
A rust library to list printers and print files on windows and unix (winspool/cups)
License: MIT License
On macos it prints well, however on windows, the file is printed in text mode and not in PDF.
Directly print command works awesome but output paper has scrambled characters on it. How can we resolve this. Thank you.
NOTE: .txt files prints fine but non-latin characters appears different.
use printers;
fn main() {
let samsung_printer = printers::get_printer_by_name("SEC001599CE908B").unwrap();
samsung_printer.print_file("report.pdf");
samsung_printer.print_file("readme.txt");
}
use printers;
fn main() {
let printer = printers::get_printer_by_name("DL-888T").unwrap();
let mut data: Vec = vec![];
let mydata1 = String::from("S0056M1234-A001");
let msg1 = mydata1.into_bytes();
data.extend(b"SIZE 4,1\n");
data.extend(b"GAP 0,0\n");
data.extend(b"DIRECTION 1\n");
data.extend(b"HOME\n");
data.extend(b"CLS\n");
data.extend(b"TEXT 120,10,\"0\",0,1,1,\"");
data.extend(msg1);
data.extend(b"\"\n");
data.extend(b"BARCODE 120,50,\"128\",100,1,0,2,2,\"123456abcd123456\"\n");
data.extend(b"PRINT 1\r\n");
printer.print(&data, None).unwrap();
}The above is my code, please ask why after I run it, what is printed is the TSPL command, not the pattern formed by the command. We run it successfully on linux, but the problem I mentioned occurs on windows, can you know what is the problem
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 1', C:\Users\zhangby.cargo\registry\src\github.com-1ecc6299db9ec823\printers-1.0.2\src\windows.rs:27:37
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
error: process didn't exit successfully: target\debug\printer.exe
(exit code: 101)
Was debugging printing on Windows and ran across this deprecation warning:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/wmic
I don't have much experience with Windows development, but I'm curious if using Get-Printer
would be better:
https://learn.microsoft.com/en-us/powershell/module/printmanagement/get-printer?view=windowsserver2022-ps
how to print image. I try the print_file
, but no work. just print text file.
printer.print_file("C:\\Users\\Administrator\\Documents\\01.jpg", None);
Change orientation of page
PrinterInfo2w.Status
the value of a is always 0
Trying to determine printer status always returns 0 for offline & online printers
Hi,
Is it possible to specify the page size of the file to print? Or somehow pass parameters to the printer function?
Maybe I've simply overlooked something in the code...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.