What is a PDE?A PDE is a Printing Dialog Extension. In other words when one goes to print something and they want the advanced printing options they use a PDE. An example using the TextEdit application and a Brother 2240 printer can be seen in Figures 1 - 3. To initially get to the printing options click the Show Details button on the bottom of the printing dialog shown in Figure 1. From there notice the drop down menu labeled TextEdit. This drop down menu contains all of the printing option panels supported by both the app, the operating system, and the print driver as shown in Figure 2. By selecting the Print Settings item from the drop down the dialog automatically grows to accommodate the settings. This Print Settings dialog is the PDE.
Figure 1: Basic Print Dialog
Figure 2: Print Settings Options
Figure 3: Full Print Dialog
Who Cares About PDEs?
It turns out not many people. The major group who cares are printer manufacturers. The occasional sucker cares too. Why sucker and not something less derogatory? The documentation on PDEs and the whole of CUPS is total junk. Why care about PDEs? As a printer manufacturer or sucker one might develop a printer of some sort which has more options than just the number of copies and the paper size among a small handful of others.
So the first thing that is informative in developing PDEs is to have all of the relevant (but bad) documentation available. The following list has been conceivably helpful:
- http://www.cups.org/index.php - Contains documentation on the CUPS printing system.
- http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Printing/osxp_aboutprinting/osxp_aboutprt.html - An overview of printing in OSX, pretty useless because it is written for an app developer.
- http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf - The PPD specification. PPDs will be discussed a little later but are very important.
- http://partners.adobe.com/public/developer/en/ps/5645.PPD_Update.pdf - An update to the PPD specification.
- http://developer.apple.com/legacy/library/documentation/Printing/Conceptual/ExtPrintingDialogs/ExtPrintingDialogs.pdf - A legacy document from Apple which has not been updated. :(
- http://developer.apple.com/legacy/library/documentation/Printing/Reference/PrintingPlugin_Ref/ppiref.pdf - Another legacy document that fits with the aforementioned document.
There are probably more but I have forgotten them.
A PPD is a PostScript Printer Description file. To my understanding it tells CUPS about your printer. A PDE exposes the features defined within a PPD. PPDs also include some localization info so that the print driver options may be localized based on the operating systems language settings.
Making a PDE
Apple is generous enough to provide the OutputBinsPDE example which does not show up when you search online (at least not Google). You may find it by searching for OutputBinsPDE in the documentation or you can find it manually under Mac OS X 10.6 Core Library/Graphics & Animation/Printing/OutputBinsPDE (assuming it exists there once 10.9 hits the streets). Go ahead and click the open project button.
Figure 4: Xcode Documentation
It will automatically download (I think?) the project. Go ahead and click Run. Okay it built (with some warnings), now lets install it.
Installing the PDE
To install PDEs and PPDs navigate to: /Library/Printers/. The following steps may need authentication which is okay. Make a folder in /Library/Printers called Sample and dump the bundle you just compiled into the Sample folder. By default the downloaded example project will be placed in the Downloads folder. Next, the PPD needs to be installed. To install a PPD it first needs to be archived into a .gz folder. This may be done by first duplicating the PPD file. Rename the file to not have an extension i.e. OutputBinsPDETest. Open the terminal and navigate to downloaded project (cd ~/Downloads/OutputBinsPDE) and type gzip OutputBinsPDETest. Hit enter and notice that we now have a file named OutputBinsPDETest.gz. This file should be moved into the /Library/Printers/PPDs/Contents/Resources folder. Once this is complete we can now install a printer that uses this PPD/PDE combo by opening the System Preferences. At the add printer dialog click on the IP sub dialog. In the address go ahead and type localhost:55000 and select HP Jetdirect for the protocol. Leave the Queue field empty. See Figure 5 for a picture of the settings.
Figure 5: Printer Configuration 1
Give the printer a name and under the Use menu select Select Printer Software, Figure 6. In the Filter type Bin and select Postscript Printer Manufacturer OutputBins PDE test. If a message such as the one shown in Figure 7 pops up, click Continue. Another dialog may pop up as shown in Figure 8, press Repair and wait because it may take a while.
Figure 6: Printer Software Selection
Figure 7: Printer Software Configuration Warning 1
Figure 8: Printer Software Configuration Warning 2
Testing the PDE
Now we have the printer installed. Open TextEdit and print anything. Try to get to the advanced settings menu we just made, Figure 9. Oh no, the PDE is unsupported because it does not have a version for the current architecture Figure 10. Darn.
Figure 9: Advanced Printer Settings
Figure 10: Unsupported PDE due to Architecture
Go back to Xcode and go to the Build Settings, Figure 11. Change the Debug Architecture to Native Architecture of the Build Machine. This allows the PDE to be build for an x86_64 architecture. For a PDE to work it must match the architecture of the application which launched the print dialog. This become super hairy because some apps are build for i386 and some for x86_64, and if you are really unlucky one of the Power PC architectures. Keep that in mind if the PDE you develop is to be deployed. So now recompile and reinstall the PDE. You do not need to redo the part with the .gz file. To ensure the effects take hold quit TextEdit and force kill the printtool process in Activity Monitor. Now reprint something from TextEdit and try and navigate to the Output Bins menu, Figure 12 and 13. Cool, you now have a PDE.
Figure 11: Xcode Architectures Settings
Figure 12: Advanced Printer Settings
Figure 13: Advanced Printer Settings Panel