Baker Mail Forwarding System

From ThePlaz.com

Revision as of 18:35, 20 October 2012 by ThePlaz (Talk | contribs)

Jump to: navigation, search

thumb|The system under testing In February 2012, I built the Baker House Mail Forwarding System.

Contents

Server

I added a page where users can submit their mailing addresses to our existing dorm desk system.

I added a page to the desk worker side of the portal where desk workers can enter a name. The name is then looked up, and the forwarding info is retrieved. If the user is eligible for mail forwarding, I generate a label.

Label Generation

I build a template for the label in Adobe Illustrator. I then saved the AI file as a PDF. I then opened the PDF file in Acrobat and saved the PDF as a PS file. I then uploaded the PS file to my server. On the server, I use Find and Replace to replace my template text in the PS file on the fly. I then print the PS file on the web server.

lp -d dymo -o landscape -o MediaType=100mm -o media=Custom.1x3.5in  -o PrintDensity=Heavy label.ps

CUPS

I installed CUPS on the Baker web server. I added myself to the lpadmin group so I can administer the server from the web. I use elinks to navigate the CUPS website, because it is only available to the localhost, and I didn't want to muck with firewalls. Looking back I could have probably administered the printer using the command line. Make sure to use the right driver/PPD file! Dymo had both a LabelManager 450 and a LabelWriter 450! I wasted an hour trying to print to using the LabelManager driver - which prints very small labels!

Print Server

For testing purposes, I hooked up the Dymo to my Windows Desktop and shared the printer using Windows File and Printer Sharing. You can connect to the printer using LPD (after turning on the LPD print server in "Change Windows Features")

lpd://18.245.6.XX/dymo

I have ordered the LabelWriter Print Server to use as a permanent print server. This should be more reliable for full time usage, rather than using the desk computer or another full machine.

Printer

I am using the DYMO LabelWriter 450 Turbo label printer. It's actually a pretty good product! It appears to support PostScript pretty well! It is a thermal printer, so you don't need ink or toner. Just don't jam it! If you do, you can remove the front cover. The labels often wind up around the roller. I use a Xacto knife to cut the wound up labels straight across. I then hit the "advance" button and the pieces come right out.

Code

function print_label($name, $line1, $line2, $line3, $month, $day, $year) { $path = '/var/www/label/'; $month = intval($month); if ($month < 10) { $month = "0".$month; } $day = intval($day); if ($day < 10) { $day = "0".$day; } $year = intval($year);


exec('cp '.$path.'mail.ps '.$path.'mail_temp.ps'); exec('sed -i \'s/NameNameName/'.escape_paren($name).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/1 1 1 1 1/'.calc_kerning_title($name).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/Line1Line1Line1/'.escape_paren($line1).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/2 2 2 2 2/'.calc_kerning_body($line1).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/Line2Line2Line2/'.escape_paren($line2).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/3 3 3 3 3/'.calc_kerning_body($line2).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/Line3Line3Line3/'.escape_paren($line3).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/4 4 4 4 4/'.calc_kerning_body($line3).'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/MonthMonthMonth/'.$month.'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/DayDayDay/'.$day.'/\' '.$path.'mail_temp.ps'); exec('sed -i \'s/YearYearYear/'.$year.'/\' '.$path.'mail_temp.ps'); exec('lp -d dymo -o landscape -o MediaType=100mm -o media=Custom.1x3.5in -o PrintDensity=Heavy '.$path.'mail_temp.ps', $output); exec('rm '.$path.'mail_temp.ps');