Skip to content
This repository

Tools for exploring the possibilities of "internet of things" printing.

Octocat-spinner-32 lib Allow GET requests to print and preview with content. March 27, 2014
Octocat-spinner-32 public Migrate the project to Exciting owner. November 06, 2013
Octocat-spinner-32 support Add a simple sketch for testing the LED/switch circuit April 23, 2012
Octocat-spinner-32 test Allow GET requests to print and preview with content. March 27, 2014
Octocat-spinner-32 views Migrate the project to Exciting owner. November 06, 2013
Octocat-spinner-32 .foreman Only define the port in one place. March 23, 2012
Octocat-spinner-32 .gitignore Gitignore .bundle. April 20, 2012
Octocat-spinner-32 .travis.yml Try to patch Travis build. November 06, 2013
Octocat-spinner-32 Capfile Migrate the project to Exciting owner. November 06, 2013
Octocat-spinner-32 Gemfile Allow GET requests to print and preview with content. March 27, 2014
Octocat-spinner-32 Gemfile.lock Allow GET requests to print and preview with content. March 27, 2014
Octocat-spinner-32 LICENSE.txt Migrate the project to Exciting owner. November 06, 2013
Octocat-spinner-32 Procfile Unicorn won't respond properly to HUP without a config file. April 26, 2012
Octocat-spinner-32 README-ARDUINO.md Add README-ARDUINO.md August 02, 2012
Octocat-spinner-32 README.md Migrate the project to Exciting owner. November 06, 2013
Octocat-spinner-32 Rakefile Ensure redis configuration is set for rake queue worker tasks. October 28, 2013
Octocat-spinner-32 config.ru Store print archives in a less memory-hungry data store. September 03, 2012
Octocat-spinner-32 migrate_prints_to_database.rb Store print archives in a less memory-hungry data store. September 03, 2012
Octocat-spinner-32 printer.fzz Update the Fritzing diagram. July 25, 2012
Octocat-spinner-32 printer.ino Use latest version of Bounce Arduino library. February 20, 2014
Octocat-spinner-32 rasterise.js Ensure that the background is white. February 27, 2013
Octocat-spinner-32 remove_archive_from_redis.rb Store print archives in a less memory-hungry data store. September 03, 2012
Octocat-spinner-32 resque_pool.yml Previewing and printing both prepare pages. April 27, 2012
Octocat-spinner-32 unicorn.conf.rb Unicorn won't respond properly to HUP without a config file. April 26, 2012
README.md

Printer

Build Status

In a nutshell, Printer is a software system that makes it easy for YOU to:

Using a commonly-available small thermal printer, and some basic Arduino hardware, we can send small, designed bits of content from the internet to be printed anywhere in the world.

Find out more about getting a printer on the wiki, or the server API on the wiki.

You can also see some sample applications: Printer Mail, Printer Paint and Printer Weather.

If you're interested in the background, take a look at the project page or the introductory blog post.

This is the backend server software. The rest of this README is about setting up and running a server.

Server Setup

The server acts as a conduit for turning HTML-based designs into a format suitable for the printer. The printer periodically polls the server, and if some data for printing is available, it downloads it and prints it.

Dependencies:

  • Ruby 1.9.2 or greater
  • Bundler
  • PostgreSQL
  • Redis 2.0.0 or greater
  • ImageMagick
  • PhantomJS (1.6.0 or greater recommended for better webfont-handling)
  • Common fonts

Here's the apt-get command I ran:

apt-get install ttf-mscorefonts-installer xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic redis-server imagemagick libmagick++-dev

You may need to add multiverse sources to apt - see http://askubuntu.com/questions/59890/ttf-mscorefonts-installer-is-not-available

Installing PhantomJS

PhantomJS is used as part of the rasterisation process, which turns HTML content into bitmaps suitable for printing. In order to get the best possible output, you should use a recent version of PhantomJS. I have tested against version 1.5.0.

You can build PhantomJS by following the instructions they provide at http://code.google.com/p/phantomjs/wiki/BuildInstructions

Running the server locally

To run the printer server locally, you should simply need to install the bundle

bundle install

You may need to create the PostgreSQL database

createdb printer
createdb printer-test # if you want to run the tests

If your database requires credentials, or you choose a different database name, you can specify this by setting the DATABASE_URL environment variable. It will be something like DATABASE_URL="postgres://username:password@localhost/printer"

Finally, run all the processes using Foreman

foreman start

This will start the web application and the queue processors.

Note that if you're running the local server, you'll also need to update the Ardunio sketch to point at the right port and IP or hostname for the machine you're running the server on.

Deployment

Deployment is managed by recap (https://github.com/exciting-io/recap), a small, fast, git-based deployment strategy for capistrano.

Use bundler to install the dependencies

bundle install

Then you can deploy and set up a server as follows. Firstly, create the application user and group:

bundle exec cap bootstrap

Next, prepare the server for the application. Follow any guidance about adding your SSH user to groups, etc:

bundle exec cap deploy:setup

Finally, deploy the application:

bundle exec cap deploy

The server should start running on port 5678; I suggest you set up Apache or Nginx to reverse proxy a domain to that port.

Compatible printers

The server contains code to handle the A2 thermal printer described here, but the architecture should make it easy to implement support for other printers.

Each printer reports its "type" when it is checking with the server for content, and this corresponds to a class mapping in the PrintProcessor module. To support a new printer, it should be as simple as adding a new type to this mapping, along with the supporting class to emit the right printer byte sequences.

TODO & CAVEATS

The printer itself seems to prefer some types of paper over others, particularly where dark printing or horizontal lines are present. I've experienced paper from Staples jamming. If I find any good sources of paper, I'll update this.

Rasterisation of HTML designs isn't great at the moment; to some extent this is limited by PhantomJS, which:

  • doesn't support web fonts
  • doesn't seem to support non-antialiased rendering
  • doesn't match the exact font-sizes as seen in the browser, and this doesn't seem to be consistent either.

LICENSE

The Printer project is open source, and made available via an 'MIT License', which basically means you can do whatever you like with it as long as you retain the copyright notice and license description - see LICENSE.txt for more information.

Something went wrong with that request. Please try again.