Brian Epstein on Tue, 10 Jun 2003 13:42:04 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] CUPS printing postscript watermark filter


Ok, here's one for a group of highly intelligent beings.

I'm trying to make my linux box print a watermark on everything it 
prints.  I'm running RedHat 9 with cups-1.1.17-13.3.

I've created (ok, stolen and modified) the following perl script which 
nicely converts postscript to postscript with watermark:

----- /usr/lib/cups/filter/watermark -----
#!/usr/bin/perl
# job-id, user, title, copies, options, [filename or stdin]
 
($job_id, $user, $title, $copies, $options, $filename) = @ARGV;
 
$flag = 0;
$HOSTNAME = `hostname`;
$LOCALTIME=localtime();
chomp($HOSTNAME);
while (<>) {
    if (/^%%BeginPageSetup/) {
        print $_;
        if ($flag) {
            print "grestore\n";
        }
        $flag = 1;
        print $_;
        print "gsave\n";
        print ".95 setgray\n";
        print "/Helvetica-Bold findfont 12 scalefont setfont\n";
        print "80 80 800 { 306 exch moveto\n";
 
        print "(${user}\@${HOSTNAME}:${job_id} ${LOCALTIME}) dup\n";
        print "stringwidth pop 2 div neg 0 rmoveto show } for\n";
        print "grestore\n";
    } else {
        print;
    }
}
----- end -----

I'm trying to make it into a cups filter (as you can see from the 
script), but have been unsuccessful so far.

Any ideas?
Thanks,
ep

-- 
Brian Epstein <ep@epiary.org>
Key fingerprint = F9C8 A715 933E 6A64 C220  482B 02CF B6C8 DB7F 41B4


_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug