Printing to PDF

If you have an application that can't output natively to PDF, you can create yourself a PDF printer.

  1. Get the backend for it - look for PDF Distiller Script from
  2. Install this as 'pdf' in /usr/lib/cups/backends, and set it world executable.
  3. You may need to restart CUPS (e.g. on RedHat systems run 'service cups restart')
  4. You probably need GhostScript installed (try looking for a package called gs-common) for ps2pdf(1).
  5. Add a printer, either using the web interface (http://localhost:631/), XimianDesktop's printer interface, or the command line:
lpadmin -p PDFcreator -v pdf:/home/chris/PDFfiles -E -P /path/to/distiller.ppd

You can use any "raw" ppd you want really - I used the Raw/Raw (en) option in the installer, and it worked fine. You can download a color postscript ppd file from the cups-pdf site.

Create the printer with the URI of pdf:/where/you/want/the/output.

Easy as that. Then you can set Samba up to print to this printer via CUPS.

There are some notes on how this can be used with Samba to email PDFs to you on the SambaPDFPrinter page (Which also has a PDF Printer setup for LPRng).

There is also a cups-pdf virtual backend which can be used to print to pdf from cups. Your distribution should distribute this - for example, Debian (Sarge or Sid) users can "apt-get install cups-pdf".

Cups and SAMBA

See the SambaPrinting page for more information

Auto-discovery of printers

CUPS can do broadcasts over a network to both advertise the availability of local printers as well as to find and "proxy" for remote printers. On a LAN this is probably what you want, but if you are on the MetaNet this may result in other people seeing your printers, and you seeing theirs. This can have unpleasant side-effects: for example, my cups found remote printers that were later firewalled/disconnected or removed. Later that day when starting a GNOME application, it would hang on start-up as the gnome printing backend tried contacting the remote printers which were now un-contactable.

Anyway, the lesson is to edit cupsd.conf to disable this. (This is in the /etc/cups/ directory in Debian and RedHat.) Either disable browsing completely by adding the line
Browsing off

Or set the network/address mask for the BrowseAllow/BrowseDeny variables (for incoming broadcasts) and BrowseAddress (for outgoing broadcasts). Debian Sarge defaults to browsing on, accepting incoming information from anywhere and not sending out any information.

Examples of adding printers

Simple CUPS setup

I plugged a Epson Color Stylus 760 into the USB port of a Debian Sarge machine, and this is how I made it go:

  • Install CUPS: apt-get install cupsys cupsys-driver-gimpprint gs-esp
  • Edit /etc/cups/cupsd.conf and add Apache-like Allow stanzas at the <Location> sections at the bottom: I wanted all of my local network to be able to administer or use the printer, so I added Allow From
  • You need to have your USB drivers loaded: in my case, they were a modprobe ehci-hcd; modprobe uhci-hcd; modprobe usblp away. I put the module names in /etc/modules so they would be loaded at boot. If you want, you can use hotplug to manage USB: see HotPlugNotes. Ubuntu does this all automatically for you.
  • Navigate to http://server:631/ and log in. Use credentials of someone in the 'lpadmin' group: either add yourself, or use root.
  • Click "printers" on the top bar; click "Add a printer". Follow your nose through here. Print a test page at the end to make sure its going.

Hint: If it doesn't go, set 'LogLevel debug' in /etc/cups/cupsd.conf, restart cups, and look at /var/log/cups/error_log.

Congratulations, you now have a printer at ipp://server/printers/printername.

From an Ubuntu Dapper client, click System, Administration, Printing. Double click "New printer", set the type to CUPS printer (IPP), and add the URL above.

Follow your nose again through the rest, and then you should have a working printer.

Setting up a USB printer by the command line

These are just some observations of what I did to set up a Brother HL 1440 laser printer (using the USB port) on a machine that already had CUPS installed, and had an HP Deskjet installed. This was done on debian woody (or close enough to woody) remotely via an ssh connection. These instructions also worked perfectly for a Brother HL 1430 on a Redhat 9 system running XimianDesktop although I didn't use any of the graphic configuration tools. Hopefully these instructions are generic enough to work with any USB printer supported by cups.


Make sure the kernel has USB Printer support. I created a kernel module (CONFIG_USB_PRINTER) and made sure it installed ok.

Make a device file. I assume people using devfs don't need to do this manually. I did:

  mkdir /dev/usb
  mknod /dev/usb/lp0  c 180 0

although some people use the name "/dev/usb/usblp" instead.

Config files

Foomatic is the cups package with all the printer description files (*.PPD) and setup stuff.

To determine which driver cups needs to use, you do

   # foomatic-configure -O | less

which lists all the supported printers, and search for your printer. If I search for "1440" I find an entry for the new printer that includes the line


Now the magic line:

foomatic-configure -s cups -n Brother -c file:/dev/usb/lp0 \
    -p Brother-HL-1440 -d hl1250 -o PageSize=A4

(This should all be on one line, without the "\") This says to use the cups printing system, and name the new printer "Brother". The -p and -d options are the printer ID and driver I got from the previous step in the output. Also I used an option to set the default page size to A4.

Note that this can't be done until the printer is connected, as I got a "client-error-not-possible" error until someone at the remote end plugged the new printer into the USB port.

You can also access cups by going to http://localhost:631 and authenticating as any user in the "lpadmin" group (I used root). From here I printed a test page and made this the default printer.

You can also make it the default printer by editing /etc/cups/printers.conf or with the command "lpadmin -d Brother"


4) Edit /etc/printcap for "Legacy" applications. cups does make a printcap file, but in debian the default name is /etc/printcap.cups. Just copy that - it had empty entries for my two installed printers.

Random Hints/Printer-specific bugs/workarounds

426 Upgrade Required

Set DefaultEncryption? Never in cupsd.conf.

Wrong printer/options being used by default

remove ~/.lpoptions (for all users) as that hard-coded the default printer! I don't know what created that file, as only some users had it.

Check for a PRINTER environment variable and make sure that it's either unset or set correctly.

cupsd loading modules on startup

On my Debian and Ubuntu systems, CUPS causes the lp.ko (and parport-related) modules to be loaded. It turns out that cupsd runs all the programs in the /usr/lib/cups/backend directory, and the 'parallel' program in there explicitly loads the lp module. Remove this symlink if you want to stop this behaviour.

Brother HL-1440

CUPS will recommend and use the hl1250 PPD driver for this printer. Unfortunately, it doesn't handle the page margins quite right. Since no package seems to have a PPD file specifically for this printer, you'll have to work around it. Try one of the following methods:

1. Set some default options for this printer:

lpoptions -p <your printer> -o page-left=22 -o page-right=22 -o page-top=22 -o page-bottom=22

If you run "lpoptions" as root, the setting will be valid for all users. I can't tell what unit those distances are in, but this method worked for me. Doing so as root just puts them into the file /etc/cups/lpoptions.

2. add the following to your ppd file (/etc/cups/printer_name.ppd):

*OpenUI *Margins/Page Margins/Offsets: PickOne
*DefaultMargins: Custom
*Margins Default/Driver Default: ""
*Margins Custom/Custom: "<</.HWMargins[0 0 0 0] /Margins[150 150
*CloseUI: *Margins

(you may need to change the margins to suit).

3. change the following in your ppd file:

< VICE=hl1250%A%Z -sOutputFile=- -"
> *JCLBegin:      "<1B>%-12345X@PJL JOB<0A>@PJL SET RESOLUTION = 600<0A>"
> VICE=hl1250%A%Z -r600 -sOutputFile=- -"

(This tells the driver to use 600dpi, since the hl1250 driver apparently doesn't have the margin problems at this resolution).

4. :

The good news was that by specifying on 1200x600 and changing the drivers to 0.15 for top, left, and right and 0.20 for the bottom margin, the CUPS testpage, (postscript) and text prints look as close to their 'raw' postscript HP printer counterparts as I can get. Without changing the margin settings and using 1200x600, top lines of text would be cutoff the page, etc.

5.: Proprietary PPD file There should be an appropriate PPD file on the CD-ROM containing the windows driver that came with the printer. This might be better under CUPS than cups's ppd files. Brother have also freed up the licensing on some of their printing drivers, so maybe their ppd files will be included with cups in the future.

Useful Command-line tools

To see a list of all successful print jobs from the current machine (by all users)

lpstat -W completed -u

I've noticed that if my USB printer isn't turned on when cups is started, sometimes after turning the printer on, cups still thinks the printer isn't ready. You can manually re-enable the printer by:

cupsenable printername

For the example printer setup above, printername with be "Brother". Similarly, you can temporarily disable printing to a printer (although cups will still queue jobs for it) with

cupsdisable printername

You can check the status of a printer (ie whether cups is accepting jobs, and whether the printer is enabled or not) with

lpstat -a -p

Or if you want more info ("long listing"):

lpstat -a -l -p

Note that the order of these options matters.

Using Netatalk2 with cups

With the release of sarge, debian are now using automatic cups stuff, rather than the old lpr support.

This means you cannot just use the old papd.conf and hope it works. You'll get such wonderful things as it simply disapearing, and not removing the pid file, without any errors. Lovely thing that.

So, you'll need to do a few things.

Cups broadcasting is great, however, it's not always as great as it would seem. It can (and will in our case) pick up other cups broadcasted printers. You need to disable the reception of these printers in your config otherwise pap can also die.


in /etc/cups/cupsd.conf find the browse section, and add in, something much like the following:

#Allows browsing from the local network
#Disables printer broadcast from backup server

Make sure you have:

BrowseOrder allow,deny

Set as well.

Once this is done, edit <tt>/etc/netatalk/papd.conf<tt>, and add:


This will automatically get the cups printers, and use the ppd that cups uses.

if pap is not running, either restart netatalk in the normal way, just type papd, which starts it, uses the config, and inserts a pid file.

The logs should show something like:

Jul 15 12:13:23 host papd[16668]: restart (2.0.2)
Jul 15 12:13:23 host papd[16668]: CUPS support enabled (1.1)
Jul 15 12:13:30 host papd[16668]: Authentication disabled: SharpC150
Jul 15 12:13:30 host papd[16668]: register SharpC150:LaserWriter@zone1
Jul 15 12:13:36 host papd[16668]: Authentication disabled: hplj4-letterhead
Jul 15 12:13:36 host papd[16668]: register hplj4-letterhead:LaserWriter@zone1
Jul 15 12:13:42 host papd[16668]: Authentication disabled: hplj4
Jul 15 12:13:42 host papd[16668]: register hplj4:LaserWriter@zone1
Jul 15 12:13:48 host papd[16668]: Authentication disabled: hp8100
Jul 15 12:13:48 host papd[16668]: register hp8100:LaserWriter@zone1
Jul 15 12:13:54 host papd[16668]: Authentication disabled: hp5000
Jul 15 12:13:54 host papd[16668]: register hp5000:LaserWriter@zone1

The only error I have so far encountered, is this:

can't register SharpC150@greed:LaserWriter@zone1
Jul 15 11:24:08 host papd[7929]: Deleting CUPS temp PPD file for SharpC150_greed (/var/spool/cups/tmp/42d6f4186a35b)

This was because it was a broadcast printer, and cups didn't have a local copy of its ppd. THis is why I recommend disabling cups broadcast receive (send is fine) using BrowseDeny.

It is also possible to setup netatalk to use the cups printers, but add your own settings. I won't go into much detail due to lack of time, however,

If for example, you wanted to add a cups printer, with a different zone, and maybe running as a different user, you would enter into papd.conf:

hp5000-test2@another zone:\                        - This is the printername that will be broadcast
       :pr=hp5000:\                                - This is the cups printer that will be used (opt)
       :pd=/usr/share/lib/ppd/anotherdriver.PPD:   -The ppd you want to use (opt)

opt= optional. space constraints.


Not seeing all the drivers you want?

Debian doesn't seem to have dependencies to drag in the PPDs for all the foomatic drivers, even if you install the filters.

Install also the foomatic-filters-ppds package.

Windows printing to Cups, without Samba

There are many howtos on how to set up printing from windows clients to a printer attached to a linux computer via samba, but theres not much I could find on doing it without samba. Heres how I did it:

Linux Server Setup

  • Set up cups to work locally - this is pretty standard and I will assume you have this sussed already. Most distros tend to use cups these days. Assume your printer is, like mine, called "hp". Lets also assume the linux machine with the printer attached is called "server".
  • You need to sort cups so that it will allow access from your LAN. Assuming a LAN with addresses 192.168.1.x you need this stanza in /etc/cups/cupsd.conf
<Location /printers>
Order Deny,Allow
Allow 192.168.1.*
  • Please note that there is also the possibilty of stronger sytstems involving proper authentication, but if you are not exposing port 631 to the internet you probably aren't doing too much harm allowing it to be set up this way.
  • You can also have different permissions for different printers, if I just wanted to allow access to printer hp, but not others I would instead use:
<Location /printers/hp>
Order Deny,Allow
Allow 192.168.1.*

Windows client setup

  • On the linux box find the .PPD file relevant to your printer. For any printer that has configured, cups conveniently copies it from "somewhere on your file system" to /etc/cups/ppd/hp.ppd. Make this available to your windows computer, cups makes it available at http://server:631/printers/hp.ppd. NB! windows, in a rare fit of fussiness over case seems to require at least the .PPD extension to be capitalised. Therefore download it from your print server and rename it in capitals. (1)
  • Download the Adobe generic postscript driver for windows (2). Use winzip or similar to unzip them to a directory on your windows box (or use cabextract to extract it on your linux box and share it via samba)
  • Run adobe's setup program. Click through the first couple of boxes and when it asks whether the printer is local or networked, choose networked. In the next box put in the address of the printer like this (If you don't have DNS working on your lan simply use the IP address of the linux box instead of "server"):
  • The next dialog will say "The network printer is not using the Adobe driver. If you know the type of the selected printer Click Yes to install the driver...(and some other options)". Click yes and you will get a dialog box where you can browse for and choose the .PPD file you downloaded. Choose it.
  • The next dialog asks if you want it to be the printer to be the default on the windows box, and if you want to print a test page. Make your choices.
  • The next dialog gives a summary, click "Install" , or "Back" to correct errors. It then installs the driver and asks if you want to configure the printer - click yes and set up your paper preferences etc. (remember to set A4).
  • You are done. You should be able to print from windows applications. To access the printer's special features click "Advanced" in the print dialog box, it will bring up a dialog with all the options specified in the PPD file.

(1) PPD files are wonderful wonderful things. They describe the capabilities of the printer in a text file format, and are genuinely cross-platform usable. For every option setting they contain PostScript code which, embedded in the PostScript file sent to the printer, applies the corresponding setting to the job. They allow (for example) Adobe's postscript driver to be aware of the printer options on any printer that has a PPD file associated with it, even if it isn't a postscript printer. PPD files are available from a variety of places, and of course Mac-OS X wants them too, so manufacturers are releasing them more and more. Further info: (also available as pdf)

(2) - support menu, downloads, postscript printer drivers (windows) choose your language version, its about 7.5M and named winsteng.exe. It is a self-extracting zip file. UPDATE 30 April 2007: It is getting harder to find the winsteng.exe file. Adobe have changed around their website yet again. The easiest route to find it seems to be to search for "winsteng.exe" through the search box on the adobe site. Alternatively try this url, although I can't guarantee that it won't change:

See CupsAccounting

Part of CategoryPrinting