Git Product home page Git Product logo

escpos's People

Contributors

damdo avatar gnanakeethan avatar hermitcarb avatar kenshaw avatar maitredede avatar mcluseau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

escpos's Issues

Example in Readme does not compile!

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

Image format

Hi. I tried to print image but something is wrong, it prints too-many characters. Which image type I must pass to p.Image()?

Barcode Support

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))
}

License violation, no reference to original code

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.

Disable logging by default

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:

log.Printf("Writing %d bytes\n", len(data))

and here:

log.Printf("Wrote NO bytes\n")

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

Cut() Function not working for TM-T70

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

Printer Types

Hello @kenshaw
Could you please provide a list of the supported printers in this code in the read me?!

Print currency and chars with accent

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!

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.