Giter Site home page Giter Site logo

escpos's Introduction

Maven Central CircleCI License

Usage

<dependency>
  <groupId>com.github.terrytsai</groupId>
  <artifactId>escpos</artifactId>
  <version>2.2</version>
</dependency>

EscPos Library for Java

A basic Java ESC/POS implementation for receipt printers.

  • EscPosWriter provides a fluent style api for preparing ESC/POS data. Supported commands depend on printer model.
  • SerialFactory is a type-safe solution for obtaining SerialPort connections on any platform.

SerialFactory Usage

SerialPort port = SerialFactory.com(3, SerialConfig.CONFIG_9600_8N1());

port.openPort();
OutputStream out = port.getOutputStream();
// Use OutputStream
port.closePort();

EscPosWriter Usage

EscPosWriter escPos = new EscPosWriter(out)
        .initialize()
        .setCharacterCodeTable(CharacterCodeTable.PC437)
        .setJustification(Justification.CENTER)
        .setCharacterSize(Width.X3, Height.X3)
        .setEmphasize(true)
        .text("HELLO WORLD")
        .printAndFeedLines(5)
        .cut(CutA.PARTIAL)
        .sendRealTimeRequestPulse(Pin.TWO, PulseTime.FOUR);

EscPosWriter Methods

Write Commands

  • text(String text)
  • bytes(byte[] bytes)

Print Commands

  • printAndFeedLine()
  • printAndReturnToStandardMode()
  • printAndCarriageReturn()
  • printInPageMode()
  • printAndFeedPaper(int n)
  • printAndReverseFeed(int n)
  • printAndFeedLines(int n)
  • printAndReverseFeedLines(int n)

Line Spacing Commands

  • setDefaultLineSpacing()
  • setLineSpacing(int n)

Character Commands

  • cancelPrintInPageMode()
  • setPrintMode(boolean altFont, boolean emphasized, boolean underlined, boolean doubleHeight, boolean doubleWidth)
  • setRightSideCharacterSpacing(int n)
  • setUnderline(Underline underline)
  • setEmphasize(boolean enabled)
  • setDoubleStrike(boolean enabled)
  • setFont(Font font)
  • setCharacterSet(CharacterSet characterSet)
  • setRotation(Rotation rotation)
  • setColor(Color color)
  • setCharacterCodeTable(CharacterCodeTable characterCodeTable)
  • setUpsideDownPrint(boolean enabled)
  • setCharacterSize(Width width, Height height)
  • setWhiteBlackReverse(boolean enabled)
  • setSmoothing(boolean enabled)

Print Position Commands

  • horizontalTab()
  • setPrintDirection(Direction direction)
  • setJustification(Justification justification)
  • setLeftMargin(int nL, int nH)
  • setPrintPositionStart(DataAction action)
  • setPrintAreaWidth(int nL, int nH)
  • setAbsolutePosition(int nL, int nH)
  • setRelativePosition(int nL, int nH)
  • setAbsoluteVerticalPosition(int nL, int nH)
  • setRelativeVerticalPosition(int nL, int nH)

Mechanism Control Commands

  • returnHome()
  • setUnidirectionalPrint(boolean enabled)
  • cut(CutA cut)
  • cutWithFeed(CutB cut, int n)
  • cutPosition(CutC cut, int n)
  • cutWithFeedAndReturnStart(CutD cut, int n)

Panel Button Commands

  • setPanelButtons(boolean enabled)

Kanji Commands

  • setKanjiPrintMode(boolean underlined, boolean doubleWidth, boolean doubleHeight)
  • setKanjiCharacterMode()
  • setKanjiUnderline(Underline underline)
  • cancelKanjiCharacterMode()
  • setKanjiCodeSystem(Kanji kanji)
  • setKanjiCharacterSpacing(int n1, int n2)
  • setKanjiQuadrupleSize(boolean enabled)

Miscellaneous Commands

  • initialize()
  • sendRealTimeRequest(RealTimeRequest realTimeRequest)
  • sendRealTimeRequestPulse(Pin pin, PulseTime pulseTime)
  • sendRealTimeRequestPowerOff()
  • sendRealTimeRequestBuzzer(int a, int n, int r, int t1, int t2)
  • sendRealTimeRequestStatus(Status status)
  • sendRealTimeRequestClearBuffers()
  • setPeripheralDevice(int n)
  • setPageMode()
  • setStandardMode()
  • generatePulse(Pin pin, int t1, int t2)
  • setMotionUnits(int x, int y)

escpos's People

Contributors

terrytsai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

escpos's Issues

USB

How do i connect to a USB printer

Cut should be send decimal values instead of hexadecimal

The cut(...) method sends hexadecimal values instead of decimal as i spec (65 and 66 decimal in spec).
0x00 and 0x01 do not need to be sent.
should also send n at end witch should say number of lines to feed before cutting.

Take a look at
https://github.com/TerryTsai/EscPos/blob/master/src/main/java/email/com/gmail/ttsai0509/escpos/EscPosBuilder.java#L149-L151

                case FULL:              out.write(0x00); out.write(0x65); break;
                case PART:              out.write(0x01); out.write(0x66); break;

should be

                case FULL:              out.write(65); out.write(0); break; // n which is number of lines to feed is set to 0 here
                case PART:              out.write(66); out.write(0); break; // n which is number of lines to feed is set to 0 here

Thanks otherwise for a great builder! Helped me to getting started with my printer.

Second Bill comes broken at the beginning.

Hello,
I'm using your library and it's works awesome. The only thing that I don't know how to solve is second and all following checks prints broken.
image
You can check it on this picture. Two same check were printed and on the second one beginning is broken and only f symbol printed. But second part of second check print's well.
Maybe I don't know how to use it?

Add Maven Repository

Add this to your readme:

<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
<dependency>
	    <groupId>com.github.TerryTsai</groupId>
	    <artifactId>EscPos</artifactId>
	    <version>0e768dea08</version>
	</dependency>

FROM:

https://jitpack.io/#TerryTsai/EscPos/0e768dea08

Its easier for users to use your lib then

Print symbols

How to print symbols like €? or special characters like áàâ㺪?

Thanks

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.