Git Product home page Git Product logo

escpos-coffee's Introduction

escpos-coffee

Java library for ESC/POS printer commands. Can send text, images and barcodes to the printer. All commands are send to one OutputStream, than you can redirect to printer, file or network.

Getting Start

The EscPos works with OutputStream to send its commands. Here we have two examples that show different output streams.

Creating printer output stream:

  PrintService printService = PrinterOutputStream.getPrintServiceByName("printerName");
  PrinterOutputStream printerOutputStream = new PrinterOutputStream(printService);
  EscPos escpos = new EscPos(printerOutputStream);
  escpos.writeLF("Hello Wold");
  escpos.feed(5);
  escpos.cut(EscPos.CutMode.FULL);
  escpos.close();

Sending hello world to system out:

  EscPos escpos = new EscPos(System.out);
  escpos.writeLF("Hello Wold");
  escpos.feed(5);
  escpos.cut(EscPos.CutMode.FULL);
  escpos.close();

See on samples directory to view more codes.

Downloading

Download code and binaries from the last release of escpos-coffee.

Compiling

I used the following development tools. But it might work with other versions or even another tools.

Apache Ant(TM) version 1.10.5

Netbeans 8.2

java version "1.8.0_172"

The project can be compiled with below commands:

cd src/escpos_coffee
ant clean
ant  jar
ant javadoc

Samples

You can find samples code on src/samples directory. Download the binaries here. how to run samples:

java -jar samplename.jar "printer name"

getstart.jar

Send info of the library to the printer.

output

textstyle.jar

Shows how to construnct one simple receipt.

output

Also this sample show how simple is to create diferent text styles, like title, subtitle, bold, etc.

  Style title = new Style()
          .setFontSize(Style.FontSize._3, Style.FontSize._3)
          .setJustification(EscPosConst.Justification.Center);

graphicsimage.jar, bitimage.jar and rasterimage.jar

Shows how to work with ImageWrapper.

Then you will see things like how to print on center-justified one image, like this:

    escpos.writeLF("print on Center");
    imageWrapper.setJustification(EscPosConst.Justification.Center);
    escpos.write(imageWrapper, escposImage);

dithering.jar

Shows how to work with BitonalThreshold and BitonalOrderedDither.

output

output

Bellow, we can see how to use ordered dither class.

  algorithm = new BitonalOrderedDither();
  escposImage = new EscPosImage(imageBufferedImage, algorithm);     
  escpos.write(imageWrapper, escposImage);

barcode.jar

Samples of barcode, PDF417 and qrcode.

output

output

output

Bellow, code to send barcode to the printer

  BarCode barcode = new BarCode();
  escpos.write(barcode, "hello barcode");

codetable.jar

Shows how to send texts from different languages.

  escpos.setCharacterCodeTable(CharacterCodeTable.CP863_Canadian_French);
  escpos.writeLF("Liberté et Fraternité.");

Versioning

Using SemVer for versioning.

Last release here.

Contributting

Contributors are wellcome, but before you do it its important to read and agree with CODE_OF_CONDUCT.md and CONTRIBUTING.md.

Acknowledgments

I would like to thanks Michael Billington and contributors for the great work on the mike42/escpos-php project that inspired me to start this project.

escpos-coffee's People

Contributors

anastaciocintra avatar papuscoder avatar

Watchers

Ederson G. Elias 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.