Using Alternate pstops

Richard Rogers richard at rogersuk.me.uk
Thu Dec 18 00:25:16 PST 2008


> The easiest way is to do the command
> lpoptions -p your_printer_name -o page-pabel=label1
> as user root from the command line.
>
> Helge
>
> --
> Helge Blischke
> Softwareentwicklung
>
> H.Blischke at acm.org
Ok, that put the correct line in the printers.conf file, but it still doesn't add the "watermark"
Obviously I am going wrong somewhere, so I will describe what I did to install everything:
1. Downloaded CUPS 1.3.9 source
2. Downloaded alternate pstops 1.9.3n
3. Unpacked CUPS and copied the pstops.c file to the filter folder of the extracted source
4. Ran /.configure
5. Ran make
6. Ran make install
7. installed various drivers (hplip, ghostscript, gutenprint, etc)
8. Created a folder called watermarks in /usr/share/cups
9. Created a file called label1 in /usr/share/cups/watermarks
10. Put the following code in label1:


%%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

% 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 CUPS_ENV_OPT/job-originating-user-name get dup length string
copy 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


11. Created the printer (a HP JetDirect device)
12. Sent a test print, which printed a test page, but no label at the top

Richie




More information about the cups mailing list