MCPcopy Index your code
hub / github.com/TerryTsai/EscPos

github.com/TerryTsai/EscPos @2.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.2 ↗ · + Follow
137 symbols 218 edges 30 files 68 documented · 50%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

CircleCI Version JitPack License

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)

Core symbols most depended-on inside this repo

write
called by 62
src/main/java/com/github/terrytsai/escpos/EscPosWriter.java
port
called by 2
src/main/java/com/github/terrytsai/escpos/serial/SerialFactory.java
bytes
called by 1
src/main/java/com/github/terrytsai/escpos/EscPosWriter.java
configure
called by 1
src/main/java/com/github/terrytsai/escpos/serial/SerialFactory.java
getBaud
called by 1
src/main/java/com/github/terrytsai/escpos/serial/config/SerialConfig.java
getDataBits
called by 1
src/main/java/com/github/terrytsai/escpos/serial/config/SerialConfig.java
getStopBits
called by 1
src/main/java/com/github/terrytsai/escpos/serial/config/SerialConfig.java
getFlowControl
called by 1
src/main/java/com/github/terrytsai/escpos/serial/config/SerialConfig.java

Shape

Method 107
Enum 28
Class 2

Languages

Java100%

Modules by API surface

src/main/java/com/github/terrytsai/escpos/EscPosWriter.java66 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/SerialConfig.java12 symbols
src/main/java/com/github/terrytsai/escpos/serial/SerialFactory.java5 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/Timeout.java2 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/StopBits.java2 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/Parity.java2 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/FlowControl.java2 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/DataBits.java2 symbols
src/main/java/com/github/terrytsai/escpos/serial/config/Baud.java2 symbols
src/main/java/com/github/terrytsai/escpos/enums/Width.java2 symbols
src/main/java/com/github/terrytsai/escpos/enums/Underline.java2 symbols
src/main/java/com/github/terrytsai/escpos/enums/Status.java2 symbols

For agents

$ claude mcp add EscPos \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact