Code Monkey home page Code Monkey logo

ticketfile's Introduction

ticketfile Build Status

What is a Ticketfile?

A Ticketfile is a textual representation of a thermal printer receipt.

It allows you to write simple readable text for your receipts rather than having to deal for example with ESC/POS specification directly.

Why would I use Ticketfiles?

Maybe you've found an ESC/POS library for your favorite language out there and you're wondering why you should use Ticketfiles instead?

Even though they're inspired by ESC/POS specification, Ticketfiles are human-readable (here is a Ticketfile and its ESC/POS equivalent) and manufacturer agnostic. In the future if a new standard emerges we'll do our best to support it without changing the spec in a breaking way.

If you use a library you'll also be tied to a language, Ticketfiles are language agnostic, it's just text. They can easily be generated through any language and templating engine.

Finally, even though they mainly target receipt printers, Ticketfiles are context agnostic. For instance, our Golang library also provides an HTML converter so that a Ticketfile can be displayed in a browser or sent as e-mail attachment.

Ticketfile specification

Full specification are available here.

Golang library usage

The Golang library contains a parser and various converters.

The most simple way to use it is through the ticket command :

go get -u github.com/bamarni/ticketfile/cmd/ticket

The following command would then convert a Ticketfile into ESC/POS commands and send them to a printer :

ticket < /path/to/ticketfile > /path/to/device

In case of a syntax error in your ticketfile, a message would be displayed to stderr while nothing would be sent to the printer device.

To convert your Ticketfile into HTML :

ticket -html < /path/to/ticketfile > receipt.html

Contributing

Contributions and new ideas are always welcome.

The Golang library is a first-class citizen so any change in the specification needs to be reflected in the Go engine.

Released under the MIT license.

ticketfile's People

Contributors

bamarni avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

Forkers

productinfo

ticketfile's Issues

bar code support

Code 39 would be a good start.

BARCODE HEIGHT ( "1" … "255" )
BARCODE WIDTH ( "1" … "255" )
BARCODE PRINT CODE39 (VALUE)

# HRI stands for Human Readable Characters
BARCODE HRI DISPLAY ("NONE" | "TOP"  | "BOTTOM" | "BOTH")
BARCODE HRI FONT ("A" | "B"  | "C" | "D" | "E")

engine should support multiple printers

Each printer should be named, the one passed as constructor argument is called MAIN. Subsequent printers would be added through the following method :

func (e *Engine) AddPrinter(name string, w io.Writer)

Printer names are not case-sensitive. New ticketfile command SELECT :

PRINTLF ...

CUT

SELECT PRINTER2

PRINT ...
CUT

add an html converter

It should be a stateful converter, all style instructions would be registered until something actually needs to be written on the receipt, the text would be wrapped inside a span tag. The init command would reset the states.

For example :

ALIGN RIGHT
COLOR RED

PRINTLF value

INIT

PRINT value2

PRINTRAW
value4
value5
>>>

CUT

Would result in :

<span style="text-align: right; color: red;">value</span>

<br />

<span>value2</span>

<div style="text-align: right; color: red;">
value4<br />
value5
</div>

<hr />

For barcodes (#1), this library could be used to generate images to be displayed : https://github.com/boombuler/barcode

Multiple spaces should be replaced by &nbsp;.

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.