Skip to content

alexandr-andreyev/escpos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

escpos

Golang package for handling ESC-POS thermal printer commands

Instalation

go get -u https://github.com/alexandr-andreyev/escpos

Usage example

package main

import (
	"https://github.com/alexandr-andreyev/escpos"
	"os"
)

func main() {
	f, err := os.OpenFile("/dev/usb/lp0", os.O_RDWR, 0)

	if err != nil {
		panic(err)
	}

	defer f.Close()

	p := escpos.New(f)
	p.Init()

	p.FontSize(2, 2)
	p.Font(escpos.FontB)
	p.FontAlign(escpos.AlignCenter)
	p.Writeln("Hello World!")
	p.Feed()

	p.FontSize(1, 1)
	p.Font(escpos.FontA)
	p.FontAlign(escpos.AlignLeft)
	p.Writeln("Lorem ipsum primis potenti in purus vestibulum amet enim, fames orci dapibus tempor...")
	p.FontAlign(escpos.AlignCenter)
	p.QRCode("https://github.com/alexandr-andreyev/escpos", true, 6, escpos.QRCodeErrorCorrectionLevelH)
	p.FeedN(10)

	p.FullCut()
}

About

Golang package for handling ESC-POS thermal printer commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%