rigsb.net

News for our friends and family

AirPrint enable your legacy printer

Posted on by Eric Rigsby
Find me at: Facebook | LinkedIn | Twitter
My LaserJet 4 working on my iPhone

My LaserJet 4 working on my iPhone

 

Objective

Share our HP LaserJet 4 with our iPads and iPhones.

Notes

If you’re using iOS devices for any type of business you’ll probably have to print a document or two eventually. Unfortunately, in order to do so via conventional means, you’ll have to buy a new printer that is AirPrint-ready or $20 software.

Today, while reading arstechnica.com I came across some news from CES that Lantronix was producing an AirPrint print server to make any networked printer AirPrint-ready. It’s going to cost $149. That prompted me to share my method for making our perfectly good, networked LaserJet 4, AirPrint-ready.

You’ll need a Mac. I’m still running OS 10.6.8 on my Mac Mini. You also need to share your networked printer from your Mac.

  • Create a bash script with the command to create a new Bonjour service that supports AirPrint: /somewhere/airprint-hack.sh
#!/bin/bash
dns-sd -R "airprint LaserJet 4 @ mini" _ipp._tcp.,_universal . 631 txtvers=1 qtotal=1 rp=printers/LaserJet_4 ty="HP LaserJet 4 - Gutenprint v5.2.3" note="Office" printer-state=3 printer-type=0x1016 Transparent=T Binary=T Fax=F Color=F Duplex=T Staple=F Copies=F Collate=F Punch=F pdl=application/pdf URF=none
  • Create a new plist file that executes the script at startup: /Library/LaunchDaemons/local.mini.airprint-hack.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>local.mini.airprint-hack</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Library/LaunchDaemons/airprint-hack.sh</string>
        </array>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>1</integer>
        <key>UserName</key>
        <string>root</string>
        <key>RunAtLoad</key>
        <true/>
        <key>Keeplive</key>
        <true/>
</dict>
</plist>
  • Load the plist into launchd
 sudo launchctl load /Library/LaunchDaemons/local.mini.airprint-hack.plist
  • It should load dynamically but I restarted to test that the printer was available via AirPrint at startup.

Hints

  • I used Bonjour Browser to figure out what the Bonjour service for my shared LaserJet 4 looks like. Then, created the dns-sd command to insert into the bash script based on the Bonjour Browser output.
  • Using this method, you’ll end up with two Bonjour services for the same printer. I’m not sure what the impact is since I only have the one Mac.

  • Blaketh

    Thanks! Just what I needed to set up my printer.

  • supermariofan25

    My Terminal returns “Dubious ownership on file (skipping): /Library/LaunchDeamons/local.mini.airprint-hack.plist nothing to load” what did I do wrong???

  • http://pucknhockey.com Eric Rigsby

    Sorry. I didn’t see this until today. You need to change the ownership of the file to root. Run a sudo chown root then set the permissions with sudo chmod 644 . That should help.

  • rolando

    What is the magic in the dns-sd call that registers the shared printer specifically as an *AirPrint* printer? I do that and the service shows up in the bonjour browser, but does not appear in my iOS devices. To come up with the command in the airprint-hack.sh, I just took all the parameters from the existing share in Bonjour Browser and added them. It seemed to work, but I fail to see why that would make an AirPrint service and not just a regular old shared printer.

  • http://pucknhockey.com Eric Rigsby

    It’s been a while…

    The key is the pdl parameter “pdl=application/pdf”.

  • Manutoky

    Thanks for this! To print pictures/images just extend this phrase:
    pdl=application/pdf,image/jpeg,image/urf

  • The Flying Badger

    Didn’t work for me. The service created (and appears in bonjour browser), but my iPhone still can’t find any printers. Thoughts?