I bought an HP2840 Color LaserJet, and wanted to use it in
Postscript mode, but CUPS in
Linux doesn't automatically upload document required fonts. I call this script from
rc.local so that it runs when I start my computer. Make sure your printer is on first. The script sends data to the
JetDirect port 9100.
#!/bin/sh
#The next line restarts using tclkit \
exec `which tclkit` "$0" ${1+"$@"}
# package name -- fontupload.tcl
#
# Abstract: sent type1 postscript fonts to network laserjet directjet
#
# usage: fontupload.tcl 192.168.0.6 /usr/share/ghostscript/fonts
set host [lindex $argv 0]
set fontdir [lindex $argv 1]
puts "$host $fontdir"
set count 0
set err 1
while {$err && $count < 100} {
puts "connecting $count"
set err [catch {set sock [socket $host 9100]}]
incr count
after 5000
}
puts $sock "serverdict begin 0 exitserver"
foreach font [glob -directory $fontdir *.pfa] {
puts "uploading $font"
set fh [open [file join $fontdir $font] r]
puts $sock [read $fh]
close $fh
}
puts $sock "%%EOF"
close $sock