Skip to content
/ escpos Public
forked from kenshaw/escpos

A simple Golang package for handling Epson ESC-POS printer commands. It also provides a simple TM-Intelligent/ePOS-XML server implementation.

License

Notifications You must be signed in to change notification settings

ISI-nc/escpos

This branch is 1 commit ahead of, 11 commits behind kenshaw/escpos:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Kenneth Shaw
Feb 21, 2018
50a50ef · Feb 21, 2018

History

19 Commits
Feb 21, 2018
Feb 19, 2018
Feb 21, 2018
Aug 22, 2015
Feb 21, 2018
Feb 21, 2018
Feb 21, 2018
Feb 21, 2018
Feb 21, 2018
Feb 21, 2018

Repository files navigation

About escpos

This is a simple Go package that provides ESC-POS library functions to help with sending control codes to a ESC-POS capable printer such as an Epson TM-T82 or similar.

These printers are often used in retail environments in conjunction with a point-of-sale (POS) system.

Installation

Install the package via the following:

go get -u github.com/kenshaw/escpos

Example epos-server

An example EPOS server implementation is available in the cmd/epos-server subdirectory of this project. This example server is more or less compatible with Epson TM-Intelligent printers and print server implementations.

Usage

The escpos package can be used similarly to the following:

package main

import (
    "bufio"
    "os"

    "github.com/kenshaw/escpos"
)

func main() {
    f, err := os.Open("/dev/usb/lp3")
    if err != nil {
        panic(err)
    }
    defer f.Close()

    w := bufio.NewWriter(f)
    p := escpos.New(w)

    p.Init()
    p.SetSmooth(1)
    p.SetFontSize(2, 3)
    p.SetFont("A")
    p.Write("test ")
    p.SetFont("B")
    p.Write("test2 ")
    p.SetFont("C")
    p.Write("test3 ")
    p.Formfeed()

    p.SetFont("B")
    p.SetFontSize(1, 1)

    p.SetEmphasize(1)
    p.Write("halle")
    p.Formfeed()

    p.SetUnderline(1)
    p.SetFontSize(4, 4)
    p.Write("halle")

    p.SetReverse(1)
    p.SetFontSize(2, 4)
    p.Write("halle")
    p.Formfeed()

    p.SetFont("C")
    p.SetFontSize(8, 8)
    p.Write("halle")
    p.FormfeedN(5)

    p.Cut()
    p.End()

    w.Flush()
}

TODO

  • Fix barcode/image support

About

A simple Golang package for handling Epson ESC-POS printer commands. It also provides a simple TM-Intelligent/ePOS-XML server implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%