Script to fix pagesize problem on HP650C

Here is the script to insert the PageSize command into a postscript file in order to keep an HP650C from wasting vast amounts of paper. First I am including the "meat" of the script--the part that we actually use here. It just looks at the file and if it is not a postscript, assumes that it is hpgl2 and sends it on with an lpr command. If it is postscript, then it uses awk to get the BoundingBox size, and uses sed to put in the proper Pagesize command, and then sends the new temporary file on to the printer. We didn't use the full script, because we bought the software from HP that handles the switching from hpgl2 to postscript. At the end of this message I have included the full script as Michael A. DeAngelo of the USGS sent to me.

There are funny origin problems. Often the bottom and/or left side of a plot is cut off. You might have to put a box around the plot to get the entire thing to print. The script doesn't work if you are using embedded eps files. In that case you will have to edit the final eps file by hand, and put in the proper PageSize command.


if [ "`head -1 ${1} | grep '^%!PS'" = "" ] # if not a PostScript file then dump to printer then lpr -s -Php650c $1 else SIZE=`head -20 ${1} | grep BoundingBox | \ awk '{MAXX = 2642; MINX = 595 MAXY = 129600; MINY = 595 X=$2+$4; Y=$3+$5 if (X > MAXX) X=MAXX else if ( X < MINX ) X=MINX if (Y > MAXY) Y=MAXY else if ( Y < MINY ) Y=MINY print X+100,Y+100}'` sed "/EndComments/a\\ << /PageSize [ ${SIZE} ] /ImagingBBox null \ >> setpagedevice" ${1} \ > /image/postscript/tmpfile.eps lpr -s -r -Php650c /image/postscript/tmpfile.eps fi
Our AML that calls this (we call it inkjet.aml) looks like this:
&args file &if [null %file%] &then &return USAGE: inkjet <file> &if ^ [exist %file% -file] &then &return Could not find %file% &sys sh /home/local/650pagesize.sh %file% &return
Here is the text of the note that Michael DeAngelo sent to me: In article <2h1mbp$5s4@dis2qvarsa.er.usgs.gov>, deangelo@ws03dwatcm.wr.usgs.GOV (Michael A. DeAngelo) writes: I made a model script which can be used to solve the PageSize problem on the HP650C in PostScript mode. When plotting a PostScript file generated by ARC to the HP650C it always cuts a ~54" page regardless of the size of the plot. The problem is that ARC doesn't produce a PostScript file which sets up the device. This model script will check to see if the PostScript file is from ARC, if it is, it will add the /PageSize command to the ARC file before piping it to the device. The PageSize values are read from the %%BoundingBox line in the PostScript file. The model assumes the plotter language is set to HPGL/2. This model will automatically switch between HPGL/2 and PostScript. I am still working on the minor origin problem we are having. ======================= # # hp650c - HP DesignJet 650C Interface Script for asynchronous # Sets line to 19200 baud # # Interface script changed by Michael DeAngelo, USGS, to be # used with a HP DesignJet 650C with the PostScript option # in HPGL/2 mode. Interface will check to see if the plot # is PostScript, if so then it will switch the plotter to PS # plot the file, then switch back. 12-10-93 # PageSize modification added 1-10-94 # BAUD=19200 # # PARAMETERS: # This interface is called with the following parameters: # # $0 - interface name - "interface/'printer_name'" # $1 - Request id returned by lp # $2 - Logname of user making request # $3 - Optional title specified by user # $4 - Number of copies specified by user # $5 - Blank seperated list of options - none apply to this interface # $6+- Filenames to be printed # # EXIT CODES: # This interface returns codes that are interpreted by "lpsched" # as follows: # 0 - Print job was completed successfully # 1 to 64 - A problem code that does not affect future jobs # 1 - Bad options list # # 65 - 127 - If the problem detected affects future jobs, the # printer will be disabled. Exit codes are then: # 65 - Can not execute filter - /usr/lib/lptab # # over 127 - Reserved for internal use by lpsched. # # check options - none apply to this printer interface #if [ ! -z "$5" ] #then # exit 1 #fi # check if filter is executable if [ ! -x /usr/lib/lptab ] then disable -r"Can not execute /usr/lib/lptab" `basename $0` exit 65 fi # stty $BAUD opost -onlret clocal ff0 cr0 nl0 0<&1 copies=$4 shift 5 files="$*" i=1 while [ $i -le $copies ] do for file in $files do if [ "`head -1 ${file} | grep '^%!PS'" = "" ] # if not a PostScript file then dump to printer then /usr/lib/lptab < $file 2>&1 else # is a PostScript file so switch to PostScript # plot file # then switch back echo "\033%-12345X@PJL ENTER LANGUAGE=POSTSCRIPT" # if an ARC/INFO file then add the PageSize line # computed from the BoundingBox line if [ "`head ${file} | grep 'Creator: ARC/INFO'" != "" ] then SIZE=`head -20 ${file} | grep BoundingBox | \ awk '{MAXX = 2642; MINX = 595 MAXY = 129600; MINY = 595 X=$2+$4; Y=$3+$5 if (X > MAXX) X=MAXX else if ( X < MINX ) X=MINX if (Y > MAXY) Y=MAXY else if ( Y < MINY ) Y=MINY print X+100,Y+100}'` sed "/EndComments/a\\ << /PageSize [ ${SIZE} ] /ImagingBBox null \ >> setpagedevice" ${file} \ | /usr/lib/lptab 2>&1 # otherwise just dump the PostScript file without # changing the file else /usr/lib/lptab < $file 2>&1 fi # switch back echo "\033%-12345X@PJL" fi done i=`expr $i + 1` done exit 0 -- ___________________________________________________________________.._________ 1201 Pacific Ave. Suite 600 | .. __ __ Tacoma, WA 98402 | <>{ D(#_],_/__/ (206)593-6510 FAX (206)593-6514 | <>{ __/~~~' ================end included message============================
Hope this helps, erich