obrennan@CC3.CC.UMR.EDU (obrennan) (12/05/90)
My apologies for posting this long item to the net, but Bob Shaw of Texas Instruments
was interested in using the Apollo for a remote print server for a Postscript printer
and building a banner page ahead of the Postscript file. I couldn't respond to Bob
directly, so here goes:
Sorry it took so long to respond. We are currently working on a problem with
Apollo concerning certain Postscript files. These files will print just fine
with the PRF command, but somehow the file is truncated when using lpr and
pc= in the printcap file. It is not because of the banner filter however (I
tried it with and without). Our latest thought is the PRFLIB and applying
patch M0160. I will let you know, once I get the patch tape in and have installed,
whether or not the new PRFLIB fixes the truncation problem. Here is what I have to
date in my /etc/printcap file (I have tried all kinds of other options to rid the
truncation problem then eliminated them because they didn't affect the outcome):
ccpost|M/CS 116 Central Distributions HP Laserjet Postscript:\
:pc=/com/prf -pr ccpost -npag -trans -headers off -banner off:\
:lp=/dev/null:sh:sf:mx=#0:\
:if=//cc1/usr/spool/lpd/postscript.filter:\
:sd=//cc1/usr/spool/lpd/ccpost:
Here are the filter programs that place a banner page ahead of the postscript file.
We originally wrote the filter program in the shell, but thought perhaps the shell
was picking up the cntrl/d in the Postscript file and closing the standard input
prematurely, and thus wrote one in C:
-----------------------------------------------------------------------------------------
#!/bin/csh
set dt = `date`
set dt = `echo "$dt" | sed 's/.........$//'`
echo $* >//cc1/usr/spool/lpd/ps.filt.echo
set userid = $5
set node = $7
set job = $9
set userid = `echo $userid | tr a-z A-Z`
set job = `echo $job | tr a-z A-Z`
set node = `echo $node | tr a-z A-Z`
set dt = `echo $dt | tr a-z A-Z`
if (($node == "NOVELL")) then
set userid = $job
endif
echo $userid $node $job >>//cc1/usr/spool/lpd/ps.filt.echo
echo "%! "
echo "/boxshade 0.98 def % box shading"
echo "/shift 0.05 def % shade/shadow shift"
echo "/inch {72 mul} def % stack: x => 72x"
echo "%"
echo "% Draw Box Routine"
echo "% "
echo "/box {newpath % stack: x y len width "
echo " /width exch inch def "
echo " /len exch inch def"
echo " /y exch inch def"
echo " /x exch inch def"
echo " x y moveto "
echo " len 0 rlineto "
echo " 0 0 width sub rlineto"
echo " 0 len sub 0 rlineto"
echo " 0 width rlineto"
echo " closepath} def "
echo "/regtxt {"
echo " /txt exch def"
echo " /size exch def"
echo " /y exch inch def"
echo " /x exch inch def"
echo " /Courier-Bold findfont"
echo " size scalefont setfont"
echo " x y moveto "
echo " 0 setgray"
echo " txt show "
echo " } def"
echo "/shadow {"
echo " /txt exch def"
echo " /size exch def"
echo " /y exch inch def"
echo " /x exch inch def"
echo " /change shift size mul def"
echo " /Helvetica-Bold findfont"
echo " size scalefont setfont"
echo " 0.2 setlinewidth"
echo " x y moveto "
echo " 0 setgray"
echo " txt show "
echo " x y moveto"
echo " change 0 change sub rmoveto "
echo " 1 setgray "
echo " txt true charpath gsave fill grestore"
echo " 0 setgray stroke"
echo " } def"
echo "/shade {"
echo " /txt exch def"
echo " /size exch def"
echo " /y exch inch def"
echo " /x exch inch def"
echo " /change shift size 0.5 mul mul def"
echo " /Helvetica-Bold findfont "
echo " 0.4 setlinewidth"
echo " size scalefont setfont "
echo " x y moveto"
echo " 0.9 -0.1 0 {setgray txt show change 0 change sub translate x y moveto} for"
echo " 1 setgray txt true charpath gsave fill grestore "
echo " 0 setgray stroke"
echo " } def "
echo "2 setlinewidth"
echo "0.5 10.5 7.5 2.0 box "
echo "gsave"
echo "boxshade setgray fill"
echo "grestore"
echo "0 setgray stroke"
echo "0.5 8.0 7.5 2.75 box"
echo "gsave"
echo "boxshade setgray fill"
echo "grestore"
echo "0 setgray stroke"
echo " 0.8 7.15 30 (NAME: $userid) regtxt"
echo " 0.8 6.5 30 (SYSTEM: $node) regtxt"
echo " 0.8 5.85 30 (DATE: $dt) regtxt"
echo " 3.75 9.95 30 (MISSOURI'S) shadow"
echo " 4.0 9.35 30 (TECHNOLOGICAL) shadow"
echo " 4.25 8.75 30 (UNIVERSITY) shadow"
echo " 0.75 9.35 72 (UMR) shade"
echo "showpage"
cat
-------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <time.h>
main( int argc, char *argv[] )
{
long *tloc;
char *dloc;
long timeret;
char *userid, *node, *job,*parms,onechar;
userid = (char *)argv[5];
node = (char *)argv[7];
job = (char *)argv[9];
if (strcmp(node,"NOVELL") == 0) userid = job;
tloc = &timeret;
timeret = time(tloc);
dloc = ctime(tloc);
printf( "%s \n", "%! ");
printf( "%s \n", "/boxshade 0.98 def % box shading");
printf( "%s \n", "/shift 0.05 def % shade/shadow shift");
printf( "%s \n", "/inch {72 mul} def % stack: x => 72x");
printf( "%s \n", "%");
printf( "%s \n", "% Draw Box Routine");
printf( "%s \n", "% ");
printf( "%s \n", "/box {newpath % stack: x y len width ");
printf( "%s \n", " /width exch inch def ");
printf( "%s \n", " /len exch inch def");
printf( "%s \n", " /y exch inch def");
printf( "%s \n", " /x exch inch def");
printf( "%s \n", " x y moveto ");
printf( "%s \n", " len 0 rlineto ");
printf( "%s \n", " 0 0 width sub rlineto");
printf( "%s \n", " 0 len sub 0 rlineto");
printf( "%s \n", " 0 width rlineto");
printf( "%s \n", " closepath} def ");
printf( "%s \n", "/regtxt {");
printf( "%s \n", " /txt exch def");
printf( "%s \n", " /size exch def");
printf( "%s \n", " /y exch inch def");
printf( "%s \n", " /x exch inch def");
printf( "%s \n", " /Courier-Bold findfont");
printf( "%s \n", " size scalefont setfont");
printf( "%s \n", " x y moveto ");
printf( "%s \n", " 0 setgray");
printf( "%s \n", " txt show ");
printf( "%s \n", " } def");
printf( "%s \n", "/shadow {");
printf( "%s \n", " /txt exch def");
printf( "%s \n", " /size exch def");
printf( "%s \n", " /y exch inch def");
printf( "%s \n", " /x exch inch def");
printf( "%s \n", " /change shift size mul def");
printf( "%s \n", " /Helvetica-Bold findfont");
printf( "%s \n", " size scalefont setfont");
printf( "%s \n", " 0.2 setlinewidth");
printf( "%s \n", " x y moveto ");
printf( "%s \n", " 0 setgray");
printf( "%s \n", " txt show ");
printf( "%s \n", " x y moveto");
printf( "%s \n", " change 0 change sub rmoveto ");
printf( "%s \n", " 1 setgray ");
printf( "%s \n", " txt true charpath gsave fill grestore");
printf( "%s \n", " 0 setgray stroke");
printf( "%s \n", " } def");
printf( "%s \n", "/shade {");
printf( "%s \n", " /txt exch def");
printf( "%s \n", " /size exch def");
printf( "%s \n", " /y exch inch def");
printf( "%s \n", " /x exch inch def");
printf( "%s \n", " /change shift size 0.5 mul mul def");
printf( "%s \n", " /Helvetica-Bold findfont ");
printf( "%s \n", " 0.4 setlinewidth");
printf( "%s \n", " size scalefont setfont ");
printf( "%s \n", " x y moveto");
printf( "%s \n", " 0.9 -0.1 0 {setgray txt show change 0 change sub translate x y moveto} for");
printf( "%s \n", " 1 setgray txt true charpath gsave fill grestore ");
printf( "%s \n", " 0 setgray stroke");
printf( "%s \n", " } def ");
printf( "%s \n", "2 setlinewidth");
printf( "%s \n", "0.5 10.5 7.5 2.0 box ");
printf( "%s \n", "gsave");
printf( "%s \n", "boxshade setgray fill");
printf( "%s \n", "grestore");
printf( "%s \n", "0 setgray stroke");
printf( "%s \n", "0.5 8.0 7.5 2.75 box");
printf( "%s \n", "gsave");
printf( "%s \n", "boxshade setgray fill");
printf( "%s \n", "grestore");
printf( "%s \n", "0 setgray stroke");
printf( "%s %s %s \n", " 0.8 7.15 30 (NAME: ",userid,") regtxt");
printf( "%s %s %s \n", " 0.8 6.5 30 (SYSTEM: ",node,") regtxt" );
printf( "%s %.19s %s \n", " 0.8 5.85 30 (DATE: ",dloc,") regtxt");
printf( "%s \n", " 3.75 9.95 30 (MISSOURI'S) shadow");
printf( "%s \n", " 4.0 9.35 30 (TECHNOLOGICAL) shadow");
printf( "%s \n", " 4.25 8.75 30 (UNIVERSITY) shadow");
printf( "%s \n", " 0.75 9.35 72 (UMR) shade");
printf( "%s \n", "showpage" );
while ((onechar = getc(stdin)) != -1)
putc(onechar,stdout);
}
----------------------------------------------------------------------------------------
Note, these are oversimplified programs. You could do more error checking, or possibly
determine whether or not the file is ascii or Postscript then build the banner accordingly
since the Apollo print server for POSTSC has an ascii--->Postscript filter.
Gerry O'Brennan
Programmer/Analyst II
Computing Services
University of Missouri - Rolla
------------------------------
obrennan@apollo.cc.umr.edu
c0022@umrvmb.umr.edu
------------------------------