Giter Site home page Giter Site logo

escpos's Introduction

EscPos Library for Java

A basic Java ESC/POS implementation for receipt printers.

  • EscPosBuilder provides a fluent style api for preparing ESC/POS data.
  • SerialFactory is a type-safe solution for obtaining SerialPort connections on any platform.

EscPosBuilder Usage

EscPosBuilder escPos = new EscPosBuilder();

byte[] data = escPos.initialize()
        .font(Font.EMPHASIZED)
        .align(Align.CENTER)
        .text("HELLO WORLD")
        .feed(5)
        .cut(Cut.PART)
        .getBytes();

SerialFactory Usage

SerialPort port = SerialFactory.jSerialPort("COM3", SerialConfig.CONFIG_9600_8N1());

port.openPort();
port.getOutputStream().write(data);
port.closePort();

EscPosBuilder Methods

initialize(); Printer initialization command (0x1B40)

reset(); Resets the buffer

close(); Closes the buffer

getBytes(); Returns the current buffer as a byte[]

raw(val); Print a raw int, byte or byte[] to the buffer

text(String text); Print text to the buffer (will not print until feed(int lines) is called)

feed(int lines); Prints the preceding text and feeds the number of lines

font(Font font); Toggle one of the following fonts:

  • Font.REGULAR
  • Font.DH
  • Font.DW
  • Font.DWDH
  • Font.EMPHASIZED
  • Font.DH_EMPHASIZED
  • Font.DW_EMPHASIZED
  • Font.DWDH_EMPHASIZED

align(Align align); Toggle text alignment:

  • Align.LEFT
  • Align.CENTER
  • Align.RIGHT

cut(Cut cut, int lines); Feeds the number of lines and cuts the paper:

  • Cut.FULL
  • Cut.PART

kick(DrawerKick kick, int t1Pulse, int t2Pulse); Send Drawer Kick pulse to the following pin:

  • DrawerKick.PIN2
  • DrawerKick.PIN5

escpos's People

Contributors

terrytsai avatar

Watchers

James Cloos avatar ymxk 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.