Welcome to the new location of Alien's Wiki, sharing a single dokuwiki install with the SlackDocs Wiki.
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | slackware:cups [2006/11/08 20:56] – alien | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Printing with CUPS ====== | ||
+ | FIXME __this page is a work in progress__ FIXME | ||
+ | |||
+ | CUPS (the //Common UNIX Printing System//) is now the default printing subsystem in Slackware, after years of faithful service by // | ||
+ | CUPS has a browser-based graphical user interface (check out yours at [[http:// | ||
+ | Not everything can be done through the graphical interface though. The basic initial setup of the CUPS service is still a matter of hand-editing certain configuration files. | ||
+ | |||
+ | ===== Setting up the CUPS service ===== | ||
+ | |||
+ | Slackware comes with a functional CUPS server out of the box. All you have to do is make the file ''/ | ||
+ | chmod +x / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ==== / | ||
+ | |||
+ | ==== Creating print queues ==== | ||
+ | |||
+ | ==== Securing the admin web interface ==== | ||
+ | |||
+ | |||
+ | ===== Configuring CUPS clients ===== | ||
+ | |||
+ | TODO | ||
+ | |||
+ | ===== Making CUPS work with Samba ===== | ||
+ | |||
+ | TODO | ||
+ | |||
+ | ===== A PDF printer for CUPS ===== | ||
+ | |||
+ | Usually, the CUPS print queues will print to paper of course. But there are cases when you want an electronic image of some document, or web page, that you do not need on paper. The [[wp> | ||
+ | So, we need to add a print queue to CUPS which does not print our submitted jobs to paper sheets but instead generates a PDF file from our input, and makes this file available to us in some way.\\ | ||
+ | This section describes exactly how to set this up, leaving the choice up to you whether you want your PDF files delivered to you via email, or have them dumped into a directory of your choice.\\ | ||
+ | This setup uses no proprietary software to create the PDF files - all you need is already present on your Slackware machine. For those with several computers in a network, having a CUPS server to generate the PDF's has the additional advantage that it does not matter what the client computer is. Your Linux and Windows workstation, | ||
+ | |||
+ | If you are running a network server with Samba, your CUPS pdfprinter will be integrated into the Samba configuration if you tell it to use CUPS for printing support (which is the default behaviour anyway). Windows clients will be able to generate PDF's by using a Samba print queue. | ||
+ | |||
+ | I came across an implementation of a PDF printer that supports CUPS and Samba. It can be found at [[http:// | ||
+ | |||
+ | ==== Required software ==== | ||
+ | |||
+ | You will need to meet the following software requirements on your CUPS machine: | ||
+ | * CUPS installed and configured (naturally) | ||
+ | * GhostScript installed | ||
+ | Only if you want to deliver PDF files by email, you'll need these too: | ||
+ | * Sendmail configured to deliver emails | ||
+ | * Perl installed, with the additional module MIME:: | ||
+ | |||
+ | ==== Installing a new CUPS backend ==== | ||
+ | |||
+ | CUPS uses so-called // | ||
+ | We are going to create a __new__ backend, which supports printing to PDF files and delivering these files to the correct end location (mailbox or directory path). The backend is going to be called **pdf** since that name is not yet being used. | ||
+ | |||
+ | * First off, let's start with creating the necessary directories (as root). The PDF files are going to be output to a temporary location (the //spool// directory) before being emailed to their final destination. We'll be using a new directory "''/ | ||
+ | mkdir -p / | ||
+ | chmod 1777 / | ||
+ | mkdir / | ||
+ | chmod 775 / | ||
+ | </ | ||
+ | |||
+ | * Defining the new " | ||
+ | chmod 755 / | ||
+ | </ | ||
+ | |||
+ | * All right, we will now create the two scripts that will do all the hard work for us. Install the two files "'' | ||
+ | chmod 755 / | ||
+ | chmod 755 / | ||
+ | </ | ||
+ | ## Normally the PDF file will be emailed to the creating user. | ||
+ | ## Alternatively, | ||
+ | ## but leave the file on the server and restrict access by others: | ||
+ | #if [ " | ||
+ | # $MAILBIN $2 $OUTPUTFILENAME | ||
+ | # rm -f $OUTPUTFILENAME | ||
+ | #fi | ||
+ | if [ " | ||
+ | chown $2 $OUTPUTFILENAME | ||
+ | chmod 700 $OUTPUTFILENAME | ||
+ | fi | ||
+ | exit 0 | ||
+ | </ | ||
+ | |||
+ | * CUPS uses //PPD// files (PostScript Printer Definition files) for outputting correctly formatted print data. For our PDF backend, we will need a PPD file that can output color information in PostScript format (if you prefer grey-scale PDF files, you should of course get an appropriate non-colour PPD file).\\ Adobe wrote a PPD file '' | ||
+ | gzip / | ||
+ | |||
+ | * Finally, we need to restart the CUPS service to activate our new '' | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | * Using the commandline tool '' | ||
+ | lpadmin -p pdfprinter -v pdf:/ | ||
+ | </ | ||
+ | |||
+ | We're ready! The PDF printer setup is complete. | ||
+ | |||
+ | |||
+ | ==== Using the PDF printer ==== | ||
+ | |||
+ | Client computers (or you on your local computer) can create a PDF file of any printable data, by just printing to the CUPS print queue "// | ||
+ | |||
+ | If you have a network with Windows computers, the best thing is to setup a Samba server on the CUPS server and let Samba use CUPS for printing. That way, our " | ||
+ | |||
+ | |||
+ | ===== PDF Printer Scripts ===== | ||
+ | |||
+ | * Script ''/ | ||
+ | #!/bin/sh | ||
+ | # ------------------------------------------------------------------- | ||
+ | # "/ | ||
+ | # ------------------------------------------------------------------- | ||
+ | # | ||
+ | PDFBIN=/ | ||
+ | MAILBIN=/ | ||
+ | FILENAME= | ||
+ | # filename of the PDF File | ||
+ | PRINTTIME=`date +%Y-%m-%d_%H.%M.%S` | ||
+ | # no argument, prints available URIs | ||
+ | if [ $# -eq 0 ]; then | ||
+ | if [ ! -x " | ||
+ | exit 0 | ||
+ | fi | ||
+ | echo " | ||
+ | exit 0 | ||
+ | fi | ||
+ | # case of wrong number of arguments | ||
+ | if [ $# -ne 5 -a $# -ne 6 ]; then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | # get PDF directory from device URI, and check write status | ||
+ | PDFDIR=${DEVICE_URI# | ||
+ | if [ ! -d " | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | # generate output filename | ||
+ | OUTPUTFILENAME= | ||
+ | if [ " | ||
+ | OUTPUTFILENAME=" | ||
+ | else | ||
+ | if [ " | ||
+ | OUTPUTFILENAME=" | ||
+ | else | ||
+ | OUTPUTFILENAME=" | ||
+ | fi | ||
+ | echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" | ||
+ | fi | ||
+ | # run ghostscript | ||
+ | if [ $# -eq 6 ]; then | ||
+ | $PDFBIN $6 $OUTPUTFILENAME >& /dev/null | ||
+ | else | ||
+ | $PDFBIN - $OUTPUTFILENAME >& /dev/null | ||
+ | fi | ||
+ | |||
+ | # Make the file visible (but read-only except for owner); | ||
+ | # This is only needed when the username ($2) is not set, | ||
+ | # for instance when printing a test page from the web interface. | ||
+ | chmod 644 $OUTPUTFILENAME | ||
+ | |||
+ | ## Normally the PDF file will be emailed to the creating user. | ||
+ | ## Alternatively, | ||
+ | ## but leave the file on the server and restrict access by others: | ||
+ | if [ " | ||
+ | $MAILBIN $2 $OUTPUTFILENAME | ||
+ | rm -f $OUTPUTFILENAME | ||
+ | fi | ||
+ | #if [ " | ||
+ | # chown $2 $OUTPUTFILENAME | ||
+ | # chmod 700 $OUTPUTFILENAME | ||
+ | #fi | ||
+ | exit 0 | ||
+ | |||
+ | # EOF | ||
+ | # ------------------------------------------------------------------- | ||
+ | </ | ||
+ | |||
+ | |||
+ | * Script ''/ | ||
+ | #!/bin/sh | ||
+ | # ------------------------------------------------------------------- | ||
+ | # "/ | ||
+ | # Convert PostScript to PDF. | ||
+ | # ------------------------------------------------------------------- | ||
+ | |||
+ | OPTIONS="" | ||
+ | while true | ||
+ | do | ||
+ | case " | ||
+ | -*) OPTIONS=" | ||
+ | *) break ;; | ||
+ | |||
+ | esac | ||
+ | shift | ||
+ | done | ||
+ | |||
+ | if [ $# -lt 1 -o $# -gt 2 ]; then | ||
+ | echo " | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | infile=$1; | ||
+ | |||
+ | if [ $# -eq 1 ] | ||
+ | then | ||
+ | outfile=$1 | ||
+ | else | ||
+ | outfile=$2 | ||
+ | fi | ||
+ | |||
+ | # Doing an initial ' | ||
+ | exec gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ | ||
+ | -sOutputFile=$outfile $OPTIONS -c save pop -f $infile | ||
+ | |||
+ | # EOF | ||
+ | # ------------------------------------------------------------------- | ||
+ | </ | ||
+ | |||
+ | |||
+ | * Script ''/ | ||
+ | # | ||
+ | # ------------------------------------------------------------------- | ||
+ | # "/ | ||
+ | # Parameter: Username, PDF File | ||
+ | # ------------------------------------------------------------------- | ||
+ | use MIME:: | ||
+ | # Get the ARGS | ||
+ | $to = $ARGV[0]; | ||
+ | $pdffile = $ARGV[1]; | ||
+ | # Set some variables | ||
+ | $mailpipe = '| / | ||
+ | $from = " | ||
+ | $subject ="PDF File"; | ||
+ | $content = "Your PDF print"; | ||
+ | # create the mail | ||
+ | my $mail = MIME:: | ||
+ | From => $from, | ||
+ | To => $to, | ||
+ | Subject => $subject, | ||
+ | Data => $content | ||
+ | ); | ||
+ | # Attach the pdf file | ||
+ | $mail-> | ||
+ | | ||
+ | | ||
+ | ); | ||
+ | # Open mailpipe and send the mail | ||
+ | open MAIL, " | ||
+ | $mail-> | ||
+ | close MAIL; | ||
+ | |||
+ | # EOF | ||
+ | # ------------------------------------------------------------------- | ||
+ | </ |