Friday, October 19, 2007



I've been (against my will) put in charge of the server side of printing. I've said many times that the paperless office is the way to go, and I've never believed it as much as I do now.

Let's remember: All offices are only a giant trash can fire away from the ideal paperless state.

Anyway, Hewlett-Packard uses a universal printer language to communicate between the printer and the computer. It is pretty well-documented and actually uses a lot of actual plain English words.

This language facilitates printer status reports, print job communication, paper tray state, file system commands and the separation of concurrent jobs.

Most importantly, even a Windows user can download the Perl scripting binaries and access and modify this code to do all kinds of productivity enhancing things.

For example, those little blue led status displays are the perfect size for the phrase "INSERT COIN".

This is only slightly less relevant than the standard message.

I'm also amazed by how few people ever look at the status screen on HP printers.

This is the code, slightly modified with a random message generator. Just insert the IP of the printer you want to "enhance" and either select a message or leave it random. Also, feel free to change them to whatever suits your mood.


namespace hphack
  using System;
  using System.Text;
  using System.Net;
  using System.Net.Sockets;

  public class PrnHack
    public static int Main(string[] args)
        return -1;
      Console.WriteLine("\nHP Display Hack");
      Console.WriteLine("Host: {0}", args[0]);
      Console.WriteLine("Message: {0}\n", message);
      IPEndPoint ipEndPoint;
      ipEndPoint = new IPEndPoint( Dns.Resolve(args[0]).AddressList[0], PJL_PORT);

      Console.WriteLine("Host is {0}", ipEndPoint.ToString());

      Socket socket;
      socket = new Socket(


      byte [] sendData;
      string sendString;

      sendString = String.Format(
                "\x1B%-12345X@PJL RDYMSG DISPLAY = \"{0}\"\r\n\x1B%-12345X\r\n",

      sendData = Encoding.ASCII.GetBytes(sendString);
      int result;
      result = socket.Send(sendData, sendData.Length, 0);

      if(result == 0)
        Console.WriteLine("Could not send on socket");
      return 0;

    protected static bool ParseArgs(string[] args)
      if(args.Length != 2)
                  "HP Display Hack: " +
                  "hphack printername \"message\" "
        return false;

      if(args[1].Length > 16)
        Console.WriteLine("Message must be <= 16 characters");
        return false;
      if(args[1].CompareTo("random") == 0)
        message = GetRandomMessage();
        message = args[1];

      return true;

    public static string GetRandomMessage()
      string [] Messages = {
                             "NINJAS RULE", 
                             "SET TO STUN",
                             "SCORE = 3418",
                             "FEED ME",
                             "TALK TO ME",
                             "IN DISTRESS",
                             "GO AWAY",
                             "NO PRINT FOR YOU",
                             "RADIATION LEAK",
                             "I R IN UR PRINTR",
                             "PRESS MY BUTTON",
                             "HI N00B KTHXBYE",
                             "NICE HAIR",
                             "NEEDS COFFEE",
                             "BE GENTLE",
                             "TPS REPORT",
                             "EMAIL BORES ME",
                             "INSERT COIN",
                             "BLACK SABBATH"

      Random r = new Random();
      return Messages[r.Next() % Messages.Length];

    protected const int PJL_PORT = 9100;
    protected static string message = "NO MESSAGE";



I doubt you need special access to do any of this. If your company locks down their PCL code they are more paranoid than any place I've ever worked.

The toughest part might be installing Perl on a controlled work-issued PC.


Here is a version that runs from a USB thumbdrive. No install, no problem.

We never had this conversation.

No comments: