PPD Concepts

A PostScript printer description (PPD) file is a text file that contains keywords and other information to specify printer features, options, and settings. PPD files are created by printer vendors for a specific PostScript printer or printer family, and must comply with Adobe’s PostScript Printer Description File Format Specification. OS X parses the contents of a PPD file to discover the features provided by a printer, and then uses that information to build a user interface and supply PostScript code to invoke the feature settings chosen by the user.

This chapter

PostScript Printer Description Files

There are two types of keywords in a PPD file: main and options. Main keywords describe a printer’s features, such as page size (*PageSize) and font (*Font). Option keywords describe the options associated with a feature, such as Letter and Legal for *PageSize. Listing 2-1 shows an excerpt from a PPD file. In each case, the main keyword *TraySwitch is followed by an option keyword and the PostScript code to invoke that option.

Main keywords have two subclasses: default and query keywords. Default keywords always have Default in the prefix and indicate the default setting for a feature associated with a main keyword, such as *DefaultTraySwitch.

Query keywords are associated with PostScript code that can be downloaded to a printer to get information about the printer’s current state. For example, the query keyword *?TraySwitch in Listing 2-1 is followed by PostScript code that, when executed in the printer, sets the paper tray used by the printer. A main keyword does not need an associated query keyword, but a query keyword is always associated with a main keyword.

Listing 1-1  An example PPD file entry for the tray switch option

*OpenUI *TraySwitch/Tray Switching: Boolean
*OrderDependency: 20 AnySetup *TraySwitch
*DefaultTraySwitch: False
*TraySwitch True/True: "1 dict dup /TraySwitch true put setpagedevice"
*TraySwitch False/False: "1 dict dup /TraySwitch false put setpagedevice"
*?TraySwitch: "
   save
   currentpagedevice /TraySwitch get
   {(True)}{(False)}ifelse = flush
   restore
"
*End
*CloseUI: *TraySwitch

Some main keywords in a PPD file are included to build the interface that allows a user to choose the settings for a print job. These are called structure keywords. The two keyword pairs that are important for OS X PPD files are *OpenGroup/*CloseGroup and *OpenUI/*CloseUI. You need to know about these keywords if you want to take advantage of the Printer Features pane (see The Printer Features Pane in the Print Dialog).

The *OpenGroup/*CloseGroup keywords are optional and are used to group features that should appear together in the user interface. A string value must be provided with the *OpenGroup/*CloseGroup keywords to specify the name of the group. Listing 2-2 shows an excerpt from a PPD file that describes a group. The first line *OpenGroup: Finishing/Finishing Options and the last line *CloseGroup: Finishing enclose a list of features that should appear in the user interface as a group. The translation string Finishing Options specifies the label to use in the user interface for the group.

Listing 1-2  Specifying a group of Finishing features in a PPD file

*OpenGroup: Finishing/Finishing Options
*OpenUI *FoldType/Fold Type: PickOne
*DefaultFoldType: None
*FoldType Fan/Fan: "% postscript code to invoke Fan fold "
*FoldType Saddle/Saddle: "% postscript code to invoke Saddle fold "
*FoldType Wing/Wing: "% postscript code to invoke Wing fold "
*FoldType None/None: "% postscript code to invoke no fold "
*CloseUI: *FoldType
 
*OpenUI *BannerSheet/Banner Sheet: Boolean
*DefaultBannerSheet False:
*BannerSheet True/True: "% postscript code to invoke a banner sheet "
*BannerSheet False/False: "% postscript code to turn off a banner sheet "
*CloseUI: *BannerSheet
 
*CloseGroup: Finishing

The *OpenUI/*CloseUI keywords are used to enclose keywords and values that describe printer features the user may select. In OS X, the *OpenUI keyword can take Boolean and PickOne options. A PickOne list is one in which a user may choose only one item from a list of available options. (The PickMany option is not supported even though it is listed in the PostScript Printer Description File Format Specification.)

Listing 2-2 shows two features defined by the *OpenUI keyword— fold type and banner sheet. Fold type is a feature that has four options—fan, saddle, wing, and none. In OS X, the options appear on a pop-up menu titled Fold Type, with None as the default setting. Banner Sheet is a Boolean option that can be on (True) or off (False). The default is off. In OS X, this option appears as a checkbox labelled Banner Sheet.

Although Listing 2-2 shows the *OpenUI features enclosed by the *OpenGroup/*CloseGroup keywords, the grouping keywords are optional. Grouping keywords provide printer vendors with the opportunity to control which features appear together in the user interface. You can find more information on defining groups in Specifying Grouping in the Printer Features Pane.

For more detailed information on PPD keywords and syntax, see PostScript Printer Description File Format Specification, available from Adobe Developer Support:

http://partners.adobe.com/

The Printer Features Pane in the Print Dialog

In OS X, Apple provides panes in the Print dialog for the most common printer features. These panes include Copies & Pages, Layout, Output Options, Paper Feed, Error Handling, Duplex, and Summary. Whether a pane appears in the Print dialog depends on the printer’s specific features. Two of these panes are available only for PostScript printers—Paper Feed and Error Handling. See Inside OS X: About the OS X Printing System for a description and an example of each of these panes. What if your PostScript printer has some less than common features that are not in these Apple-provided panes? As a developer, you have two choices: create a custom pane or use the Printer Features pane provided by Apple for PostScript printers.

You can create a custom pane for a printer by writing a printing dialog extension (PDE). Inside OS X: Extending Printing Dialogs provides details on writing a printing dialog extension. You should also see Adding PPD Keywords to a PDE’s Information Property List for information on what you must do to register the PPD keywords that are supported by your custom printing dialog extension.

Although the Printer Features pane does not give you as much control over the user interface as creating a custom pane does, it provides a fairly easy way for you to make features accessible in the user interface. This remainder of this section describes the Printer Features pane and discusses what you must do to have your printer’s features appear in this pane.

Printer Features is a pane in the Print dialog that is available only for PostScript printers. Figure 2-1 shows a sample Printer Features pane. For a feature to appear in this pane, the feature must be defined in the PostScript printer description file as follows.

The OS X printing system follows these rules to construct the Printer Features pane:

Figure 1-1  A Printer Features pane in which the printing system groups the features
A Printer Features pane in which the printing system groups the features

See Specifying Grouping in the Printer Features Pane for more information on how printer vendors can use grouping keywords to control the layout of the Printer Features pane.

Figure 1-2  A Printer Features pane in which groups are specified in the PPD file
A Printer Features pane in which groups are specified in the PPD file

How OS X Searches for and Chooses PPD Files

OS X searches for a PostScript printer’s PPD file when a user creates a print queue. OS X automatically searches for PPD files in the appropriate localized folder. First, it looks in the en.lproj folder in following locations, in this order:

If it finds a PPD file for the printer in the en.lproj folder, it then looks for the localized PPD file in the language folder for the currently active language. See Installing PPD Files for information on localized folders.

If OS X doesn’t find a PPD file for a PostScript printer in either location, it looks in the Classic System Folder, provided the Classic environment has been run once or the Classic System Folder has been selected at least once in the Startup Disk pane of System Preferences. In other words, OS X must know of the existence of the Classic System Folder.

:System Folder:Extensions:Printer Descriptions:

Choosing a PPD File

When a user adds a PostScript printer that’s connected through a bi-directional connection such as AppleTalk or USB, they can choose Auto Select, a printer model from the Printer Model pop-up menu, or Other. A user who chooses Other can select a PPD file that’s in a nonstandard location.

If a user chooses Auto Select, OS X makes the selection by matching the value of the PPD’s *Product keyword with the name returned by sending the printer a query. For example, a PPD file that contains this keyword and value.

*Product: “(LaserWriter 8500)”

identifies the printer model LaserWriter 8500. This must match the value of the *Product keyword returned from the printer in response to a PostScript query.

Users must select the PPD file for a line printer remote (lpr) printer from a pop-up menu. For best results, they should select the PPD file that’s provided specifically for that printer.

Searching for PPD Files in the Classic Environment

If an application is running in the Classic environment, the LaserWriter 8 driver looks for PPD files in the Classic System Folder:

:System Folder:Extensions:Printer Descriptions: