Skip to content

golang library for espos printers, supporting images, barcodes and qr codes

License

Notifications You must be signed in to change notification settings

AurumAustralis/escpos

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About escpos GoDoc

This is a Golang package that provides ESC-POS library functions to help with sending control codes to a ESC-POS thermal printer.

It was largely inspired by seer-robotics/escpos but is a complete rewrite.

It implements the protocol described in this Command Manual

Current featureset

  • Initializing the Printer
  • Toggling Underline mode
  • Toggling Bold text
  • Toggling upside-down character printing
  • Toggling Reverse mode
  • Linespace settings
  • Rotated characters
  • Align text
  • Default ASCII Charset, Western Europe and GBK encoding
  • Character size settings
  • UPC-A, UPC-E, EAN13, EAN8 Barcodes
  • QR Codes
  • Standard printing mode
  • Image Printing
  • Printing of predefined NV images

Installation

Install the package via the following:

go get -u github.com/hennedo/escpos

Usage

The escpos package can be used as the following:

package main

import (
	"github.com/hennedo/escpos"
	"net"
)

func main() {
	socket, err := net.Dial("tcp", "192.168.8.40:9100")
	if err != nil {
		println(err.Error())
	}
	defer socket.Close()

	p := escpos.New(socket)

	p.Bold(true).Size(2, 2).Write("Hello World")
	p.LineFeed()
	p.Bold(false).Underline(2).Justify(escpos.JustifyCenter).Write("this is underlined")
	p.LineFeed()
	p.QRCode("https://github.com/hennedo/escpos", true, 10, escpos.QRCodeErrorCorrectionLevelH)



	// You need to use either p.Print() or p.PrintAndCut() at the end to send the data to the printer.
	p.PrintAndCut()
}

About

golang library for espos printers, supporting images, barcodes and qr codes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%