As promised to someone quite a while ago...someone asked how to create a PDF writer for linux that can be setup somewhat like the "PDFWriter" under the windows environment. Here is the answer....but the for life of me...I can't remember who asked for this????
Oh yeah....you MUST upgrade to at least CUPS 1.1 or you don't the PDF output option in the printer definitions.... First off....giving credit where it is due...here's where I got the base information..however this PERL script has some bugs in it. 1. It writes to someplace wierd and assumes directories that don't exist anymore. 2. The instructions don't tell you that in order for this to work, you need to create a "PDF" directory under each user's home directory....something like: /home/username/PDF 3. Then this program only creates the PDF file with owner root and group root...not terribly useful if you have a lot of users. So our version of the script fixes this, and changes the owner and group to the username that started the print job. We didn't change much, but the PERL still had to be changed to fix the ownership issue. Where to start: http://slowest.net/docs/howtos/print/freepdf.html This is the fixed PERL script: <start your snipping after this line and call it pdffile> #!/usr/bin/perl # CUPS PDF Writer Backend # # December 2002 # Craig Ringer and Ryan Armanasco # # License: GPL # # Version: ***SERIOUSLY*** Beta # # Firstly some explanation: # # This is a Perl executable that CUPS considers a backend when you stick # it in /usr/lib/cups/backend (or equivalent in your distribution) # # CUPS creates a temporary file of the print job, the location of which it # passes as the 6th arguement to this script. # # This file is a postscript file and is read in and sent to ps2pdf to create # the PDF file # # CUPS expects this script to output certain information to correctly # identify it as a backend when it is called with no arguements - this is # handles in the first few lines of code. # # The arguements passed to this script by cups are: # # 459 | burrol | ScanImage01 | 1 | | /var/spool/cups/d00459-001 # # $ARGV[0] - print job number # $ARGV[1] - username # $ARGV[2] - print job name # $ARGV[3] - page count i think # $ARGV[4] - i forget now - it is always blank though # $ARGV[5] - temporary print job location use strict; use vars qw(); # DEBUG stuff - last minute - no error checking :) system('env > /tmp/pdfenv'); # CUPS server uses this to identify backends # backends are required to spit this out when # no arguements are given if ( scalar(@ARGV) == 0 ) { print "network pdffile \"Unknown\" \"PDF File output\"\n"; exit; } undef $/; # get ready to log stuff - who knows why we named it ERRLOG :) open(ERRLOG,'>/tmp/pdferr') or die "failed to open error log: $!\n"; print ERRLOG join(' | ',@ARGV); print ERRLOG "\n".$ARGV[1]; print ERRLOG "\n"; # if the PDF directory exists for the designated user: if ( -d "/home/".$ARGV[1]."/PDF") { # strip possible bad chars from print job name: \ / : ; " ' < > * ? | . $ARGV[2] =~ s#[\\\/:;"`<>\*\?\|\.]#_#g; # prepare the deed open(PS2PDF,'|/usr/bin/ps2pdf - /home/'.$ARGV[1].'/PDF/"'.$ARGV[2].'.pdf"') or print ERRLOG "Arrggh, failed to open pipe to ps2pdf: $!\n", exit; } # open the temporary file CUPS creates of the print job open(CUPSSPOOL,$ARGV[5]) or print ERRLOG "couldn't open $ARGV[5]: $!\n", exit; # spit the print job at ps2pdf print PS2PDF scalar(<CUPSSPOOL>); #finish off close(PS2PDF) or print ERRLOG "Failed to close pipe to ps2pdf: $!\n", exit; close(CUPSSPOOL) or print ERRLOG "failed to close $ARGV[5]: $!\n", exit; # Give the user permissions to the end result my $resultfile = '/home/'.$ARGV[1].'/PDF/'.$ARGV[2].'.pdf'; `chown $ARGV[1] $resultfile ` ; `chgrp $ARGV[1] $resultfile ` ; close(ERRLOG); # END