GithubHelp home page GithubHelp logo

valcinei / restful-printing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nathanstitt/restful-printing

0.0 1.0 0.0 112 KB

A lightweight cors-enabled rest api for interfacing with a Cups print server

Ruby 100.00%

restful-printing's Introduction

Restful Printing


This is a small webservice that layers a light REST interface over the Cups printing system.

My purpose in writing this is was because I needed a way to print barcode labels from LedgerBuddy.

To do so is typically fairly simple and involves sending plain text which conforms to the ZPLII printing language directly to the printer port.

The problem arose when I needed to do so from a web application. Since browsers (understandably) don't support ZPL, they don't know what to do with it, and there's not a javascript api for native printing (thankfully, that would be a mess).

To use this, you'll need to

  • Setup a ZPL compatible (Tested with Zebra S4m) printer using a the raw (textonly) Cups driver on a local server.
  • Install Restful Printing service on the server.
    • At the moment there's no fancy installer and such, just:
    • For Ubuntu you'll need the following:
      • sudo apt-get install build-essential checkinstall ruby1.9.1 ruby1.9.1-dev libcups2-dev libcurl4-openssl-dev
    • Checkout the source from github and run bundle install
    • Point your favorite rack webserver at the directory. Tested with Puma and Passenger, but anything should work.
  • Send ZPL formatted text such as:
^XA
^LH30,30
^F020,10^AD^FDZEBRA^FS
^F020,60,B3^FDAAAAA01^FS
^X2

The endpoints currently defined are:

  • All available printers:

    • GET /printers(.:format)
  • All jobs for printer :name:

    • GET /printers/:name/jobs(.:format)
  • Create new print job for printer :name. Must have either a :url, or :data parameter specified:

    • POST /printers/:name/jobs(.:format)
  • return data associated with a job (currently only it's status is reported):

    • GET /printers/:name/jobs/:job_id(.:format)

The listing is also printed to STDOUT when the server is started up.

restful-printing's People

Contributors

nathanstitt avatar

Watchers

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