Skip to content

mect/go-escpos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-escpos

This is a Go library to talk to escpos capable devices, mainly the Epson POS printers.

it will allow you to send print jobs in a simple functional interface, this library also supports automatic discovery of USB devices.

This library works with both Go and TinyGo (for microcontrollers).

Documentation can be found on pkg.go.dev

Example

package main

import (
	"fmt"

	"github.com/mect/go-escpos"
)

func main() {
	p, err := escpos.NewUSBPrinterByPath("") // empry string will do a self discovery
	if err != nil {
		fmt.Println(err)
		return
	}

	p.Init() // start
	p.Smooth(true) // use smootth printing
	p.Size(2, 2) // set font size
	p.PrintLn("HELLO GO")

	p.Size(1, 1)
	p.Font(escpos.FontB) // change font
	p.PrintLn("This is a test of MECT go-escpos")
	p.Font(escpos.FontA)

	p.Align(escpos.AlignRight) // change alignment
	p.PrintLn("An all Go\neasy to use\nEpson POS Printer library")
	p.Align(escpos.AlignLeft)

	p.Size(2, 2)
	p.PrintLn("* No magic numbers")
	p.PrintLn("* ISO8859-15 ŠÙþþØrt")
	p.Underline(true)
	p.PrintLn("* Extended layout")
	p.Underline(false)
	p.PrintLn("* All in Go!")

	p.Align(escpos.AlignCenter)
	p.Barcode("MECT", escpos.BarcodeTypeCODE39) // print barcode
	p.Align(escpos.AlignLeft)

	p.FeedN(2) // feed 2
	p.Cut() // cut
	p.End() // stop
}

(The TinyGo example can be found in demo-tinygo)

Limitations

  • The USB discovery only works on Linux due to the use of udev

(PRs to fix these welcome!)

Known to work with

  • Epson TM-20III

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages