Giter Site home page Giter Site logo

escpos's Introduction

About escpos GoDoc

FOSSA Status Go Reference

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.SetConfig(escpos.ConfigEpsonTMT20II)

	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()
}

Disable features

As the library sets all the styling parameters again for each call of Write, you might run into compatibility issues. Therefore it is possible to deactivate features. To do so, use a predefined config (available for all printers listed under Compatibility) right after the escpos.New call

p := escpos.New(socket)
p.SetConfig(escpos.ConfigEpsonTMT20II) // predefined config for the Epson TM-T20II

// or for example

p.SetConfig(escpos.PrinterConfig(DisableUnderline: true))

Compatibility

This is a (not complete) list of supported and tested devices.

Manufacturer Model Styling Barcodes QR Codes Images
Epson TM-T20II
Epson TM-T88II ☑️
UpsideDown Printing not supported

License

FOSSA Status

escpos's People

Contributors

david-yappeter avatar fossabot avatar hennedo avatar naikrovek avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.