Setting up a PDF printer in CUPS (in my case in Slackware)
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
By Tinkster at 2005-10-07 03:48
Note: for this to work CUPS needs to be installed and functional.
CUPS is very powerful, with its backends and filters very interesting things can be done. One of the many possible uses is to create a printer-type PDF, which, when used as a print-target will create a PDF file rather than producing a print-out on a physical device.
For the following activities we need to be user root:
1. Create a sub-directory in CUPS directory sturcture
Code:
mkdir /usr/lib/cups/pdf
Put the following script into the newly created directory, e.g
Code:
vim /usr/lib/cups/pdf/ps2pdf.cups
i
Then highlight the following script with the mouse, and middle-click into the terminal session with vim open.
Code:
#!/bin/sh
# Convert PostScript to PDF.
umask 002
OPTIONS=""
while true
do
case "$1" in
-*) OPTIONS="$OPTIONS $1" ;;
*) break ;;
esac
shift
done
if [ $# -lt 1 -o $# -gt 2 ]; then
echo "Usage: `basename $0` [options...] input.ps [output.pdf]" 1>&2
exit 1
fi
infile=$1;
if [ $# -eq 1 ]
then
outfile=$1
else
outfile=$2
fi
# Doing an initial 'save' helps keep fonts from being flushed between pages.
exec gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-sOutputFile=$outfile $OPTIONS -c save pop -f $infile
exec chmod a+r $outfile
After the middle-click, press ESC, :wq<RET> to save the file, followed by a
Code:
chmod 755 /usr/lib/cups/pdf/ps2pdf.cups
to make it executable.
2. Create the backend
The next bit of our PDF printer driver goes into /usr/lib/cups/backend
The back-end directory holds several binary executables that take care of varied printing methods, e.g. parallel, usb, ...
We're now going to add a shell-script that handles pdf-files!
Code:
vim /usr/lib/cups/backend/pdf
i
As before, copy & paste time
Code:
#!/bin/sh
#
umask 002
PDFBIN=/usr/lib/cups/pdf/ps2pdf.cups
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 "$PDFBIN" ]; then
exit 0
fi
echo "direct pdf \"Unknown\" \"PDF Creator\""
exit 0
fi
# case of wrong number of arguments
if [ $# -ne 5 -a $# -ne 6 ]; then
echo "Usage: pdf job-id user title copies options [file]"
exit 1
fi
# get PDF directory from device URI, and check write status
PDFDIR=${DEVICE_URI#pdf:}
if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
echo "ERROR: directory $PDFDIR not writable"
exit 1
fi
# generate output filename
OUTPUTFILENAME=
if [ "$3" = "" ]; then
OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
if [ "$2" != "" ]; then
OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
else
OUTPUTFILENAME="$PDFDIR/$PRINTTIME.pdf"
fi
echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
fi
# run ghostscript
if [ $# -eq 6 ]; then
$PDFBIN $6 $OUTPUTFILENAME >& /dev/null
else
$PDFBIN - $OUTPUTFILENAME >& /dev/null
fi
exit 0
And as before, this script needs to be made executable, too.
Code:
chmod 755 /usr/lib/cups/backend/pdf
3. Download and install distiller.ppd
The printer definition file for distiller is freely available from the adobe-website, if you have a windows-installation handy follow steps 1 to 5 of the instructions...
If you don't: there's some other sites on the web that hold just the ppd rather than an installer. Google is your friend.
Once you have downloaded it add it to your CUPS' printer-model
directory:
cp distiller.ppd /usr/share/cups/model/distiller.ppd
and then, the second to last step:
4. Create the printer object
To be able to use all the pre-requisits that held us up ....
Code:
lpadmin -p PDF -v pdf:/directory/of/your/choice/ -E -P /usr/share/cups/model/distiller.ppd
5. Re-start CUPS
Now that all the set-up and installation is done, we need to let the CUPS daemon know about the new printer, too.
To achieve that we restart the daemon.
Code:
/etc/rc.d/rc.cups restart
And if all went well we should now have a printer-object that will create PDFs for us.
Need more information on the adobe distiller ppd install, the file that I had after the install was adist5.ppd under the \winxx\system32\spool\drivers\w32x86 directory, not distiller.ppd - I copied it to this name.
Before step 4 (adding the printer using lpadmin),I had to restart cups by /etc/rc.d/rc.cups restart. Cups kept complaining about 'client error' until then. Apparently the 'pdf' model was not active to be specified as part of the lpadmin command without a restart.
by pchott on Thu, 2007-01-18 03:24
nice work. I need somethnig like this, but more complicated.
I wonder if it is possible to get IP address from where document was send for printing?
by hemantkr on Sun, 2007-03-11 08:35
Hi,
The given link to adobe site , http://www.adobe.com/support/techdocs/325924.html, is broken. I tried search my friend google but not able to find "printer definition file for distiller". Can anyone help me out please? From where and how I can download and install it?
Thanks.
by SuperTim on Thu, 2007-11-22 08:42
Quote:
Originally Posted by hemantkr
Hi,
The given link to adobe site , http://www.adobe.com/support/techdocs/325924.html, is broken. I tried search my friend google but not able to find "printer definition file for distiller". Can anyone help me out please? From where and how I can download and install it?
Thanks.
hemantkr:
Try this link. You need the ADIST5.PPD file, which you can then rename to distiller.ppd when you move it.
Enjoy!
- Tim
by udstx on Tue, 2007-11-27 13:29
I followed the directions (including the adist5.ppd rename).
Checked it twice but it broke.
Everything looked great until I sent a print job.
In CUPS I see the PDF printer and can start it.
It stay 'started' until a job request is issued, then it stops with the error
PDF "/usr/lib/cups/backend/pdf failed"
I verified each step and the cut/paste text.
I am using Fedora Core 6 on a P4 platform.
Any suggestions?
by farslayer on Sat, 2007-12-01 01:14
You could also install the cups-pdf package if it's available in your distribution, it will handle the PDF creation for you and drop any PDF's you print in a CUPS folder in your home directory.
Certainly not as much fun as rolling you own PDF printer though..
default@debianetch:~$ aptitude search cups-pdf
i cups-pdf - PDF printer for CUPS
I followed the directions (including the adist5.ppd rename).
Checked it twice but it broke.
Everything looked great until I sent a print job.
In CUPS I see the PDF printer and can start it.
It stay 'started' until a job request is issued, then it stops with the error
PDF "/usr/lib/cups/backend/pdf failed"
I verified each step and the cut/paste text.
I am using Fedora Core 6 on a P4 platform.
Any suggestions?
Sorry mate, almost a year late ... the problem is
(might be?) that your device-URI points at a non-
existing directory....
Guess my description with a plain cut&paste wasn't
quite clear enough, and I apologise for that ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
A couple of gotchas though.
I wonder if it is possible to get IP address from where document was send for printing?
The given link to adobe site , http://www.adobe.com/support/techdocs/325924.html, is broken. I tried search my friend google but not able to find "printer definition file for distiller". Can anyone help me out please? From where and how I can download and install it?
Thanks.
The given link to adobe site , http://www.adobe.com/support/techdocs/325924.html, is broken. I tried search my friend google but not able to find "printer definition file for distiller". Can anyone help me out please? From where and how I can download and install it?
Thanks.
Try this link. You need the ADIST5.PPD file, which you can then rename to distiller.ppd when you move it.
Enjoy!
- Tim
Checked it twice but it broke.
Everything looked great until I sent a print job.
In CUPS I see the PDF printer and can start it.
It stay 'started' until a job request is issued, then it stops with the error
PDF "/usr/lib/cups/backend/pdf failed"
I verified each step and the cut/paste text.
I am using Fedora Core 6 on a P4 platform.
Any suggestions?
Certainly not as much fun as rolling you own PDF printer though..
default@debianetch:~$ aptitude search cups-pdf
i cups-pdf - PDF printer for CUPS
cups-pdf for FedoraCore6
Checked it twice but it broke.
Everything looked great until I sent a print job.
In CUPS I see the PDF printer and can start it.
It stay 'started' until a job request is issued, then it stops with the error
PDF "/usr/lib/cups/backend/pdf failed"
I verified each step and the cut/paste text.
I am using Fedora Core 6 on a P4 platform.
Any suggestions?
(might be?) that your device-URI points at a non-
existing directory....
Guess my description with a plain cut&paste wasn't
quite clear enough, and I apologise for that ...