Skip to content

Golang package for ESC-POS thermal printer via TCP socket

License

Notifications You must be signed in to change notification settings

seer-robotics/escpos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

About escpos

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

Installation

Install the package via the following:

go get -u github.com/seer-robotics/escpos

Usage

The escpos package can be used as the following:

package main

import (
    "bufio"
    "net"

    "github.com/seer-robotics/escpos"
)

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

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

    p.Verbose = true

    p.Init()
    p.SetFontSize(2, 3)
    p.SetFont("A")
    p.Write("test1")
    p.SetFont("B")
    p.Write("test2")

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

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

    p.SetReverse(1)
    p.SetFontSize(2, 4)
    p.Write("hello")
    p.FormfeedN(10)

    p.SetAlign("center")
    p.Write("test")
    p.Linefeed()
    p.Write("test")
    p.Linefeed()
    p.Write("test")
    p.FormfeedD(200)

    p.Cut()

    w.Flush()
}

About

Golang package for ESC-POS thermal printer via TCP socket

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages