Linux Printing User Guide

# Linux Printing User Guide

Linux Printing, CUPS, UNIX, Linux Printer Servers, Mac File Conversion, PrettyPrint, Remote Printing

printers

## Currently available printers

Charlottesville: Linux, Mac

Green Bank: Linux, Mac

New Mexico: Linux, Mac

## Print Servers: Unix/Linux and Windows

All four main NRAO sites each have two parallel printer systems: one for Windows and one for Linux/Mac systems. This apparent duplication is present for historic and other reasons. This documentation is primarily aimed at documenting the rich set of features available to Linux and Mac users via the CUPS (Common Unix Printing System) servers.

## CUPS

Initial setup (if needed)
export CUPS_SERVER=printhost # (bash, ksh)
setenv CUPS_SERVER printhost # (csh, tcsh)

The Common Unix Printing System, or CUPS, is now in use at all main NRAO sites (CV, GB, AOC, VLA). This is a new, modern alternative to the old Berkeley style of printer daemon. We have a print server at each site called printhost (e.g. printhost.cv.nrao.edu). Most of our login scripts will automatically set the CUPS_SERVER variable to point at it, but in case of emergency, break into the box on the right and use whichever line is relevant. In some cases you just might have to fully qualify the hostname (i.e., use printhost.cv.nrao.edu or whatever instead of just printhost).

## Printer Names at each Site

This table offers both direct links to the print servers at each site, as well as links to more concise lists of printer names (and locations!) where available. One of the really nice things about CUPS is its web interface. By just following the links in the table below (under "Direct link to print server), you can see detailed info on all printers, jobs, etc. in real time. This really helps if you want to know what happened to an errant job, or if a large print job is done yet.

The web interface for the print servers also has an administrative section (for, guess who, administrators! Password needed) as well as complete on-line documentation for CUPS, and more.

Direct link to print server Notes
printhost.cv For Edgemont Road and Ivy Road
printhost.gb
printhost.aoc For the AOC (not VLA)
printhost.vla For the VLA site

## The Basics: Just print my darn file!

Oh Server, Print my file (dangit)
 lpr -Pprinter myfile lp -d printer myfile

CUPS gives you the best of both worlds. Whether you're used to lpr or lp, lpq or lpstat, CUPS wants to keep you happy. The basic syntax is shown in the box on the right; use whichever command you prefer. Note that the lp version has a space between the -d and the printer name.

Smart Tip: If you have the PRINTER environment variable defined (e.g., as psnet) you can omit the -Pprinter or -d printer options from the command line; CUPS will assume you want that printer (psnet in this example).

## Don't Convert, just PRINT!

CUPS is smart.

The system has many back-end filters that can almost magically convert the format you send it to the format the printer needs to have. The classic example is:

lpr -Pps1 mypic.jpg

where we just send the printer a raw JPEG file. You can also send it many other image formats (gif, png, maybe even tiff), plain text files, PostScript files, HP-GL/2 files, and even PDF files (but be warned: the conversion is based on ghostscript technology; you may get good results or not; if not, use the acrobat reader acroread to print).

Smart Tip: For text files, there are a few additional options that may prove useful. You can get a "pretty print" version of the file via:

lpr -o prettyprint myfile

This puts a header at the top of each page with the page number, job title (usually the filename), and the date. Also, C and C++ keywords are highlighted, and comment lines are italicized.

Smart Tip: you can print your text files in landscape mode via:

lpr -o landscape myfile

## Shortcuts - "Instances"

InstanceMeaning
/dup Duplex (print on both sides of paper)
/2up 2 mini-pages per page
/big Use large format paper (B usually)
/tran Use the transparency tray (if the printer has one)
/manual Use the manual feed (if there is one)
/mantran Ditto, for transparencies

These handy little things allow you to use some of the CUPS options in "shorthand"; as you can see below, some of those options involve a lot of typing. The table to the right shows what we are providing, but remember NOT ALL SHORTCUTS ARE AVAILABLE FOR ALL PRINTERS! If a printer can't physically print on "B" (large format) paper, you can't persuade it to via a /big instance.

Here's an example of actual use:

 lpr -Pps1color/trans myfile

At the time of writing, this functionality is just being rolled out and tested, so please be patient.

## Quick HOW-TO for some options

If you want gory details of command line options for lpr, etc., then look down a bit. Otherwise, try one of these recipes:

Simplex Printing
 lpr -o sides=one-sided myfile
Duplex Printing
 lpr -o sides=two-sided-long-edge myfile (Portrait)
 lpr -o sides=two-sided-short-edge myfile (landscape)
(but watch: coming soon: an easier way!).
Transparency Printing
 lpr -o media=Transparency myfile
Text in Landscape Mode
 lpr -o landscape myfile

## I want a DIFFERENT site server! (Remote printing)

There are two ways of doing this. The first is a "one-off" method, and is is so simple to anyone used to dealing with e-mail:

lpr -Pps1@printhost.cv.nrao.edu myfile

The other way is to reset your CUPS_SERVER variable (see above) so that it references the print server you want.

## Useful Print Utilities

Everyone has their favorite "special" utility to do pretty printing of plain text, whether that be a C++ source file, a Fortran subroutine, or an e-mail message. Most Unix systems have several options; the most popular and useful are listed here.

• mp: the old reliable. Does a nice job on mail messages.

• a2ps: the author's favourite. Great job on many types of file, though you should use a2ps-mail or a2ps-mail -1 for printing mail messages. Has very nice N-up capabilities (multiple pages per single page: 2, 3, 6, 9).

• nenscript: favored by some programmers. Can also do N-up displays. Like a2ps, a bit different.

• lpr -o prettyprint: CUPS built-in pretty printer.

For more details on these, see the manual pages (type "man a2ps" or similar in a terminal window).

## The gory details - all the options

CUPS has many options you can turn on or off, via command line switches. Here's a quick cheat sheet:

Command Description
lp -n nn file Print nn copies of file.
lpr -#nn file
lp -o media=ZZZ file
TypeExplanation
Letter "A" Size, 8.5 x 11
Legal 8.5 x 14
A4 European standard (8.25 x 11.75)
COM10 US #10 envelope
DL ISO DL envelope
Transparency Overhead media
Upper Upper tray
Lower Lower tray
MultiPurpose Tray
LargeCapacity Tray
Use a specific media type or tray when printing file; possible media types include those shown in the table at right. You can't use, e.g., Upper if the printer doesn't have an "Upper" tray (duh). If you use more than one, separate by commas (no spaces).
lp -o  landscape file Print file in landscape mode (wide edge of paper on top).
lp -o  raw file Print file without any filtering. CUPS will usually apply at least one filter, even on PS files destined for PS printers. Warning: use with caution; you may not get the media or paper size you expect (some printers default to "B" size 11x14 paper).
lp -o sides=option file Print on both sides (not necessary if you use, e.g., ps3dup or other duplex-defaulting print queues). Options can be two-sided-short-edge (good for landscape) or two-sided-long-edge (portrait).
lp -o page-ranges=range file Print a specific range of pages from file. The range can be a single page number, a simple range (e.g., 2-5), or a compound range (e.g., 1-4,9,7,22-24). Pages always printed in order, so page 7 appears before page 9 in last example.
lp -o page-set=option file Option can be odd or even to print out every other page of the file.
lp -o number-up=N file Print in N-up mode (N=1, 2, or 4). Does not draw a box around each sub-page; use a2ps if you want that feature.
lp -o brightness=NNN file Brighten or dim the print; default is 100. Larger numbers brighten, smaller numberd darken.
lp -o gamma=NNNN file Apply a gamma correction; larger numbers brighten. Default is 2200 to match "sRGB" specification.
lp -o cpi=NN file (Text files only) Set the characters per inch to, e.g. 8, 12.
lp -o lpi=N file (Text files only) Set the number of lines per inch.
lp -o columns=N file (Text files only) Set the number of columns of text.
lp -o page-side=value file (Text files only) side is one of left, right, top, or bottom, and value is in points (72 points per inch, 1 point=35mm).
lp -o prettyprint file (Text files only) Puts header at top of each page; also highlights C and C++ keywords and italicizes comment lines.
lp -o scaling=NNN file (Images only) 100 means fill the page as much as the aspect ratio allows. Max is 800, min is 1. Scaling of 200 causes 4 pages to be printed.
lp -o ppi=NNN file (Images only) Specify pixels per inch, from 1 to 1200. An image size 3000 x 2400 pixels fills 10x8 inches at 300 dpi. Multiple pages may be printed if it doesn't fit on one.
lp -o hue=value file (Images only) Adjust the hue rotation from -360 to +360. See the on-line documentation for details (near the end).
lp -o saturation=value file (Images only) Adjust the saturation percent, from 0 to 200. Zero makes it grayscale, 200 makes it very garish.

## HELP! My file won't print!

One of the many things that CUPS does behind the scenes is try to optimize any PostScript it gets, via a special pstops program that comes with the CUPS system. However, given the huge variety of possible sources of PostScript files, this step occasionally will not do what is expected, and should be bypassed. The usual symptom of this is when nothing gets printed (and if you're fast, you may see a transient error message on the printer's LCD screen if it has one).

The best workaround for this situation is to avoid any post-processing by CUPS with the -o raw option to the lp command. On some printers, this may unfortunately result in your job being handled not quite as you expected; as an example,, the downstairs printer in Edgemont Road, ps1, defaults to B size paper (don't ask why; it's a sore point!).