gotspl

module
v0.0.0-...-5100518 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: Apache-2.0

README

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

Directories

Path Synopsis
* Copyright 2020 Anton Globa * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.
* Copyright 2020 Anton Globa * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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