kenshaw / escpos Goto Github PK
View Code? Open in Web Editor NEWA simple Golang package for handling Epson ESC-POS printer commands. It also provides a simple TM-Intelligent/ePOS-XML server implementation.
License: MIT License
A simple Golang package for handling Epson ESC-POS printer commands. It also provides a simple TM-Intelligent/ePOS-XML server implementation.
License: MIT License
The example provided in Readme fails with following error on go build main.go
# command-line-arguments
./main.go:18:17: cannot use w (type *bufio.Writer) as type io.ReadWriter in argument to escpos.New:
*bufio.Writer does not implement io.ReadWriter (missing Read method)
go version go1.15 linux/amd64
Hi. I tried to print image but something is wrong, it prints too-many characters. Which image type I must pass to p.Image()?
I have been trying and customizing the code for printing barcode. I could not succeed in developing a proper solution.
<?php
/* ASCII constants */
const ESC = "\x1b";
const GS="\x1d";
const NUL="\x00";
/* Output an example receipt */
echo ESC."@"; // Reset to defaults
echo GS."k".chr(4)."123123".NUL; // Print barcode
echo ESC."d".chr(1); // Blank line
exit(0);
How should the above code be translated to go. I am missing something. I tried placing \x04 instead of 4 in middle. But it just prints empty line.
//barcode is string
func (e *Escpos) PrintBarcode(barcode string, format string) {
e.Write(fmt.Sprintf("\x1dk4%v\x00", barcode))
}
Hi, you took my C code (same name variables, formatting, even my comments word by word) png2pos and integrated it in your escpos. My code is released under the MIT license. Nevertheless, I could not find any mention of my copyright (and/or reference to the original code) as MIT states. Please, fix that.
First of all, thanks for this library.
One thing I noticed while using it is that it is quite chatty in that it logs every time it write any bytes to the printer.
Here:
Line 92 in 81d0344
and here:
Line 95 in 81d0344
I think this is quite useful for certain cases but quite noisy for most of the other cases, where this level of logging might not be necessary/needed.
Thus I'd like to propose if we could make the logging optional and have some sort of configuration option to enable it when needed.
Alternatively we could use the int
already returned by WriteRaw
(which is currently always returning 0), and return the number of bytes that have been written so then the caller can log the result if interested.
How does this sound?
Thanks
I need this too.
https://reference.epson-biz.com/pos/reference/
They seem to have some good drivers. Wondering if you have looked into calling their drivers ?
As the title says, I'm not sure how to connect to the POS-printer that on a USB port, windows 7
Thanks
I am using a Raspberry Pi 4 to print on a TM-T70.
Printing works fine now after I added more flush calls to the writers because before it would not print the whole text.
However, I can not get the cut function to work.
My code:
func printReceipt(content string) error {
lines := strings.Split(content, "\n")
// Open the file of the printer
printerFile, err := os.OpenFile("/dev/usb/lp0", os.O_RDWR, 0)
if err != nil {
return err
}
defer printerFile.Close()
// Initialize the printer
reader := bufio.NewReader(printerFile)
writer := bufio.NewWriter(printerFile)
readWriter := bufio.NewReadWriter(reader, writer)
printer := escpos.New(readWriter)
printer.Init()
printer.SetFontSize(1, 1)
// Write the content and cut the paper
for _, line := range lines {
printer.Write(line + "\n")
readWriter.Flush()
writer.Flush()
}
printer.FormfeedN(6)
printer.Cut()
writer.Flush()
readWriter.Flush()
printer.End()
return nil
}
Thank you very much for your library and help
Hello @kenshaw
Could you please provide a list of the supported printers in this code in the read me?!
Hi, I don't understand how to print currency symbols, like €
, and chars with accent, like è
.
I'm trying this:
p.SetLang("it")
p.Write("èéà°òçù§£$€")
but all I get is scrambled text.
Thanks for your work!
Do you support Windows system
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.