GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - fintrace/tspl2-driver: Java client to communicate to label printers that support TSPL2 (by TSC)

BranchesTags
Open more actions menu

Latest commit

 

History

219 Commits
219 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
_config.yml
_config.yml
 
 
checkstyle.xml
checkstyle.xml
 
 
license-metadata.txt
license-metadata.txt
 
 
pom.xml
pom.xml
 
 

Repository files navigation

tspl2-driver

This library will help you to communicate with TSPL2 (by TSC) based printers.

This drivers supports communication with printer over

  • USB Communication
  • Ethernet
  • Bluetooth (TODO)

Disclaimer: This is not official or supported by TSC Auto ID Technology Co., Ltd. This work is originated purely because there are no equivalent libraries exists for java to communicate to TSPL based printers.

How to use

Maven Central

Add dependency in your pom

<dependency>
    <groupId>org.fintrace.core.drivers</groupId>
    <artifactId>tspl2-driver</artifactId>
    <version>0.0.13</version>
</dependency>

Create a connection client

// USB Client
TSPLConnectionClient tsplConnectionClient = new USBConnectionClient(
        (short) xxxx, 16), // vendor id of TSPL2 based printer
        (short) xxxx, 16)); // product id of TSPL2 based printer

// Or Ethernet Client

TSPLConnectionClient tsplConnectionClient = new EthernetConnectionClient("x.x.x.x", 9100);

Initialize the printer with defaults

tsplConnectionClient.init();

Once initialized, Establish the connection

tsplConnectionClient.connect();

You may use any available device config command to overwrite the printer defaults.

Once the connection is established, Either construct the label (using fluent API) or send the plain TSPL string to print the label.

TSPLLabel tsplLabel = TSPLLabel.builder()
                .element(Size.builder().labelWidth(4f).labelLength(3f).build())
                .element(Gap.builder().labelDistance(0f).labelOffsetDistance(0f).build())
                .element(Direction.builder().printPositionAsFeed(Boolean.TRUE).build())
                .element(ClearBuffer.builder().build())
                .element(DataMatrix.builder().xCoordinate(10).yCoordinate(110).width(400)
                        .height(400).content("DMATRIX EXAMPLE 1").build())
                .element(DataMatrix.builder().xCoordinate(310).yCoordinate(110).width(400)
                        .height(400).moduleSize(6).content("DMATRIX EXAMPLE 2").build())
                .element(DataMatrix.builder().xCoordinate(10).yCoordinate(310).width(400)
                        .height(400).moduleSize(8).nbRows(18).nbCols(18)
                        .content("DMATRIX EXAMPLE 3").build())
                .element(Print.builder().nbLabels(1).nbCopies(1).build())
                .build();

tsplConnectionClient.send(tsplLabel);

The above will send the following TSPL2 code to printer

SIZE 4,3
GAP 0,0
DIRECTION 1
CLS
DMATRIX 10,110,400,400, "DMATRIX EXAMPLE 1"
DMATRIX 310,110,400,400,x6, "DMATRIX EXAMPLE 2"
DMATRIX 10,310,400,400,x8,18,18, "DMATRIX EXAMPLE 3"
PRINT 1,1

Additionally, You may use any available status poll commands to get the status of the printer. In order to get the status, you need to register the data listener so that the poll commands sends the result to listener.

tsplConnectionClient.send(TSPLStatusPollCommands.STATUS.getCommand());

To disconnect and shutdown

tsplConnectionClient.disconnect();
tsplConnectionClient.shutdown();

This library also has a nice listener pattern to receive notifications for Data and Network.

Implement DataListener to listen for data related events from printer.

Implement ClientListener to listen for the network related events.

Other documentation

Documentation about TSPL could be find here http://www.tscprinters.com/cms/upload/download_en/TSPL_TSPL2_Programming.pdf or http://mediaform.de/fileadmin/support/handbuecher/Armilla/Handbuecher/TSC_TSPL_TSPL2_Programming.pdf

Contributions

Contributions of any type are welcome. Please contact via issues to discuss further.

About

Java client to communicate to label printers that support TSPL2 (by TSC)

Topics

javaprintertsc-printertspl2tspl2-driver

Resources

Readme

Contributing

Contributing
Activity
Custom properties

Stars

95 stars

Watchers

7 watching

Forks

18 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.