escpos

package module
v0.0.0-...-0b15b30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2019 License: MIT Imports: 7 Imported by: 0

README

About escpos

This is a simple Golang 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/panjjo/escpos

Example epos-server

An example EPOS server implementation is available in the 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/panjjo/escpos"
)

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


    p := escpos.New()

    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()
     
    _,b:=p.ReadByte()
    f.Write(b)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Escpos

type Escpos struct {
	// contains filtered or unexported fields
}

func New

func New() (e *Escpos)

create Escpos printer

func (*Escpos) Barcode

func (e *Escpos) Barcode(s string)

func (*Escpos) BarcodeHRI

func (e *Escpos) BarcodeHRI(n int)

print barcode HRI

func (*Escpos) BarcodeHRIFontSize

func (e *Escpos) BarcodeHRIFontSize(n int)

print barcode HRI font size

func (*Escpos) BarcodeHigth

func (e *Escpos) BarcodeHigth(n int)

print barcode HRI font H

func (*Escpos) Cut

func (e *Escpos) Cut()

send cut

func (*Escpos) DefaultSpacing

func (e *Escpos) DefaultSpacing()

默认行间距

func (*Escpos) End

func (e *Escpos) End()

end output

func (*Escpos) Feed

func (e *Escpos) Feed(params map[string]string)

feed the printer

func (*Escpos) FeedAndCut

func (e *Escpos) FeedAndCut(params map[string]string)

feed and cut based on parameters

func (*Escpos) Formfeed

func (e *Escpos) Formfeed()

send formfeed

func (*Escpos) FormfeedN

func (e *Escpos) FormfeedN(n int)

send N formfeeds

func (*Escpos) Image

func (e *Escpos) Image(params map[string]string, data string)

write an image

func (*Escpos) Init

func (e *Escpos) Init()

init/reset printer settings

func (*Escpos) Linefeed

func (e *Escpos) Linefeed(n int)

send linefeed

func (*Escpos) MoveBaseSize

func (e *Escpos) MoveBaseSize()

水平定位

func (*Escpos) OpenBeep

func (e *Escpos) OpenBeep()

打开蜂鸣器

func (*Escpos) OpenCashBox

func (e *Escpos) OpenCashBox()

开钱箱

func (*Escpos) PrintAndFeed

func (e *Escpos) PrintAndFeed(i int)

print and feed paper

func (*Escpos) PrintPic

func (e *Escpos) PrintPic()

打印下载位图

func (*Escpos) PrintSplitLine

func (e *Escpos) PrintSplitLine(n int, s string)

func (*Escpos) PrinterImage

func (e *Escpos) PrinterImage(img image.Image)

print img 可用做打印二维码 使用33(24点双密度)

func (*Escpos) Pulse

func (e *Escpos) Pulse()

pulse (open the drawer)

func (*Escpos) ReadString

func (e *Escpos) ReadString() string

read data by buffer

func (*Escpos) Readbyte

func (e *Escpos) Readbyte() (int, []byte)

read data by buffer

func (*Escpos) SendEmphasize

func (e *Escpos) SendEmphasize()

send emphasize / doublestrike

func (*Escpos) SendFontSize

func (e *Escpos) SendFontSize()

func (*Escpos) SendMoveX

func (e *Escpos) SendMoveX(x uint16)

send move x

func (*Escpos) SendMoveY

func (e *Escpos) SendMoveY(y uint16)

send move y

func (*Escpos) SendReverse

func (e *Escpos) SendReverse()

send reverse

func (*Escpos) SendRightSpace

func (e *Escpos) SendRightSpace(n int)

set right space

func (*Escpos) SendRotate

func (e *Escpos) SendRotate()

send rotate

func (*Escpos) SendSmooth

func (e *Escpos) SendSmooth()

send smooth

func (*Escpos) SendTo

func (e *Escpos) SendTo(w io.Writer) (int, error)

send b to printer

func (*Escpos) SendUnderline

func (e *Escpos) SendUnderline()

send underline

func (*Escpos) SendUpsidedown

func (e *Escpos) SendUpsidedown()

send upsidedown

func (*Escpos) SetAlign

func (e *Escpos) SetAlign(align string)

set alignment

func (*Escpos) SetChineseOn

func (e *Escpos) SetChineseOn()

开启中文打印

func (*Escpos) SetEmphasize

func (e *Escpos) SetEmphasize(u uint8)

set emphasize

func (*Escpos) SetFont

func (e *Escpos) SetFont(font string)

set font

func (*Escpos) SetFontSize

func (e *Escpos) SetFontSize(width, height uint8)

set font size

func (*Escpos) SetLang

func (e *Escpos) SetLang(lang string)

set language -- ESC R

func (*Escpos) SetLineSpacing

func (e *Escpos) SetLineSpacing(n int)

设置行间距

func (*Escpos) SetLocation

func (e *Escpos) SetLocation(l, n int)

set location l+n*255 设置绝对打印位置

func (*Escpos) SetMoveSize

func (e *Escpos) SetMoveSize(x, y int)

设置横向和纵向移动单位

func (*Escpos) SetPrintPic

func (e *Escpos) SetPrintPic()

func (*Escpos) SetPrinterType

func (e *Escpos) SetPrinterType(n int)

设置打印模式

func (*Escpos) SetReLocation

func (e *Escpos) SetReLocation(l, n int)

设置相对打印位置

func (*Escpos) SetReverse

func (e *Escpos) SetReverse(v uint8)

set reverse

func (*Escpos) SetRotate

func (e *Escpos) SetRotate(v uint8)

set rotate

func (*Escpos) SetSmooth

func (e *Escpos) SetSmooth(v uint8)

set smooth

func (*Escpos) SetUnderline

func (e *Escpos) SetUnderline(v uint8)

set underline

func (*Escpos) SetUpsidedown

func (e *Escpos) SetUpsidedown(v uint8)

set upsidedown

func (*Escpos) Text

func (e *Escpos) Text(params map[string]string, data string)

do a block of text

func (*Escpos) Write

func (e *Escpos) Write(data string) (int, error)

write a string to the b

func (*Escpos) WriteNode

func (e *Escpos) WriteNode(name string, params map[string]string, data string)

write a "node" to the printer

func (*Escpos) WriteRaw

func (e *Escpos) WriteRaw(data []byte) (n int, err error)

write raw bytes to b

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL