Need username printed at top of page

Patrick Young pyoung at judgememorial.com
Tue Mar 20 12:03:58 PDT 2007


> Patrick Young wrote:
> > Things are going well. Thank you, Helge! Now I just have a couple PostScript questions. I added (Username: ) show before _WM_str show and (, Job ID: ) show after it. It prints Username: somename, Job ID: so I haven't blown things up yet. I tried making a call to the job-id variable but couldn't get it to work. How do I do that. Also, now the text begins in the center but moves towards the right side of page. How can it be truly centered again after I added those extra lines?
> >
> > Thank you!
> > --Patrick
> >
> >
> >>Create a directory
> >>	$CUPS_DATADIR/watermarks
> >>(The environment variable CUPS_DATADIR usually is /usr/share/cups
> >>or /usr/local/share/cups, depending on your installation)
> >>and put the following PostScript routine there
> >>---snip---
> >>%%BeginFile: label_user 1.0 0
> >>
> >>userdict begin
> >>/CUPS_label_user where
> >>{pop}
> >>{       % first call: do necessary initialisations
> >>         currentglobal true setglobal
> >>         globaldict begin
> >>         /CUPS_label_user true def               % say not yet called
> >>         end
> >>         setglobal
> >>
>             /appstr         % <str1> <str2> appstr <str3>
>             {
>                     exch dup length 2 index length add string
>                     dup dup 4 2 roll copy
>                     length 4 -1 roll putinterval
>             }bind def
>
> >>         % Define the BeginPage stuff to render the watermark to appear
> >>         % beneath the contents of every page
> >>         <<
> >>                 /BeginPage
> >>                 {
> >>                         pop
> >>                         gsave
> >>                         % job-originating-user-name contains the user name you want to put onto
> >>                         % the bottom of the page
>                             /_WM_str (Username: ) CUPS_ENV_OPT/job-originating-user-name get
> appstr def
> >>                         % Instead of Courier, use any font you know is resident on the printer
> >>                         % the first 12 is the horizontal, the second the vertical scale factor
> >>                         % in printers points (1/72 inch)
> >>                         /Courier [12 0 0 12 0 0] selectfont
> >>                         0 setgray               % assuming the user  name is to be written in black
> >>                         currentpagedevice/PageSize get aload pop % pagewidth pageheight
> >>                         pop                     % don't need this
> >>                         % the username will be written 20 points above the lower paper edge and
> >>                         % horizontally centered
> >>                         newpath
> >>                         _WM_str stringwidth pop sub 2 div 20 moveto
> >>                         _WM_str show
> >>                         grestore
> >>                }bind
> >>         >>setpagedevice
> >>
> >>}ifelse
> >>
> >>
> >>end %userdict
> >>
> >>%%EndFile
> >>---snip---
> >>and name it, e.g. "User_goes_here".
> >>
> >>Then, with the option
> >>	page-label=User_goes_here
> >>  the name of the user requesting the job will be printed
> >>near the bottom of the page (see the comments in the PostScript
> >>snippet, that are the strings beginning with a percent sign.
> >>
> >>Feel free to ask if you have more queestions.
> >>
> >>Helge
> >>
> >>
> >>
> >>--
> >>Helge Blischke
> >>Softwareentwicklung
> >>
> >>H.Blischke at acm.org
> >
> >
>
> To adjust the whole thing including your prefix string centered, see the
> modification using the appstr procedure above.
>
> As for the job ID, I didn't pass this to the PostScript job, as the job ID is
> not unique if the print job is routed to a remote CUPS server. You might use
> the job-name variable instead.
>
> If you really need to use the job ID, let me know, I'll then givbe you
> some hints where to insert the necessary C code inot pstops.c
>
> Helge
>
>
> --
> Helge Blischke
> Softwareentwicklung
>
> H.Blischke at acm.org

That makes sense about the job ID. I think having both the username and job name on the page give me enough information to lookup the job info in the CUPS web interface if I ever need to. Just out of curiosity, would a time-/datestamp also be difficult due to sending to a remote server? That's no big deal. This gives me the bulk of what I was after. And it's centered, too! :-)

Thank you for all your help, Helge!!!
--Patrick




More information about the cups mailing list