Skip to content

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

Open

Description

@lvinci

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions