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

Cut() Function not working for TM-T70 #20

Open
lvinci opened this issue Oct 24, 2021 · 0 comments
Open

Cut() Function not working for TM-T70 #20

lvinci opened this issue Oct 24, 2021 · 0 comments

Comments

@lvinci
Copy link

lvinci commented Oct 24, 2021

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

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

1 participant