Code Monkey home page Code Monkey logo

gotspl's Introduction

gotspl

visitors Build Status Test Coverage

Golang client for TSC printers (TSPL).

This library is being developed for communication and printing on TSPL/TSPL2 (by TSC) based printers.

Currently supported communication types:

  • Ethernet
  • RS232 (TODO)
  • USB (TODO)

Disclaimer: This is not official or supported by TSC Auto ID Technology Co., Ltd.

I started developing it because I could not find an appropriate library for Golang. Contributions of any type are welcome. Please contact via issues to discuss further.

How to

Create printer connection

# Initialize library 
gotspl.TSPLInitialize(gotspl.MEASUREMENT_SYSTEM_METRIC)

client := gotspl.NewEthernetTSPLClient("printer:9100")

err := client.Connect()
if err != nil {
    panic(err)
}

defer client.Disconnect()

Create label

label := gotspl.NewTSPLLabel()
label = label.Cmd(gotspl.SizeCmd().
        LabelWidth(30).
        LabelLength(20)).
    Cmd(gotspl.GapCmd().
        LabelDistance(20).
        LabelOffsetDistance(0)).
    Cmd(gotspl.SpeedCmd().PrintSpeed(4)).
    Cmd(gotspl.ClsCmd()).
    Cmd(gotspl.DataMatrixCmd().
        XCoordinate(100).
        YCoordinate(100).
        Width(300).
        Height(300).
        Content("THIS IS DATAMATRIX TEST")).
    Cmd(gotspl.PrintCmd().NumberLabels(1).NumberCopies(1))
	

Send commands to printer

err = client.SendCommandSequence(label)
if err != nil {
    panic(err)
}

TSPL Code will send to printer

SIZE 30 mm,20 mm
GAP 20 mm,0
SPEED 4
CLS
DMATRIX 100,100,300,300, "THIS IS DATAMATRIX TEST"
PRINT 1,1

Based on documentation

Official documentation about TSPL programming

Looked at this github repository (tspl2-driver) for library design patterns

gotspl's People

Contributors

mrgloba 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.