Initial introduction and hints about its usage
A very versatile component of KDEPrint is its new Filter Command Editor. Experienced power-users or curious and daring newbies can setup any external print-file filters for convenient use through a kprinter dialog. To provide you a kickstart for use, KDEPrint ships with a sample of the most important filters.
These filters work as "pre-filters", doing their job on the printfiles before they are handed to the real print-subsystem by KDEPrint. Pre-filters currently shipping with KDEPrint are listed in the table below.
What its name is: | What it is good for: | What it requires: |
"Enscript text filter" | convert text input into PostScript output | enscript |
"Gen. image to PS filter" | converting graphic file input into PostScript output | imagetops |
"Pamphlet printing filters" (various) | arrange PostScript input pages to layout resulting in pamphlet/booklet when folding (different for printers with/without duplexer) | psnup, psselect and psbook |
"PDF writer" | convert PostScript input into PDF output | ghostscript/gs |
"Multi-pages/sheet filter" | arrange various logical pages onto one sheet of paper | psnup |
"Page select/order filter" | allow selective prints of even/odd/deliberate page ranges | psselect |
If you come up with other useful filters, or if you extend the basic features of our shipped configurations -- tell us, we are glad to include your good ideas into the KDEPrint filters! [See also at the end of this chapter for some ideas or contributions sent to us from users.]
The KDE-shipped or your self-styled filter configurations work with all of the supported print subsystems -- regardless wether you use CUPS, RLPR, LPRng or standard LPD. Every one of the filters may be hooked to a certain or to several individual printers (or in the case of CUPS, to printer instance). The configurations may be saved for future automatic usage, or changed at any time. With CUPS, you can also create "instances" of a printer, which have a certain filter permanently attached to it. This way you have a far more convenient usage, as you just need to pick the instance and have everything set already..
NOTE: KDE does not ship the filters themselves, which are configures through the Filter Command Editor. It rather expects them to be present on your system. It offers a GUI configuration frontend for them.
Any meaningful "filter" may be initially set up through the Filter Command Editor. After setup, the filter can easily be called from kprinter to run with any printjob.
A print-filter is a program that takes any type of file and works on it to produced from the given input a modified output that is better fit (or preferred by you) for further print-processing. This could consist of scaling the pages, converting file formats, selecting specific areas to print, or extracting printable info from otherwise non-printable files (like MP3-tags from *.mp3-files). All what is needed is any input file format with an output that is feasible to print.
These filters are used at the first stage of KDEPrint job processing. Therefore we also call them "pre-filters".
Left: Filter Command Editor in action, working on "enscript" pre-filter.
Right: enscript pre-filter view to user -- easy option selection.
In the case of the filter's actual presence in your system (its initiating command must be in your $PATH), KDE's pre-configuration leads to a convenient access of the most important filter options (if available) through a dialog. KDEPrint can plugin any of those filters into its first stage of printfile processing.
This construction allows you to easily integrate every single third-party-filter -- past, present of future -- into KDEPrint's framework. Imagine a filter appears somewhere in the Internet, which automatically converts MS Word files into a clean PostScript print file (yes, there are projects on the way to get there!): this could be used to print, through kprinter and its pre-filter mechanism, this sort of files without a need to open them in an application first...
If you use CUPS, you may be familiar with the concept of "instances". (Instances of a given printer are a fixed set of printoptions --- like "duplex, A4, use business letter paper from tray 3" --- that may be assigned to any queue, allowing a quick access to frequently use options, saving the time to click through different menus). Various pre-filter can easily be assigned to various printer instances.
To call a pre-configured filter from kprinter (the KDEPrint printing dialog), just click on the "Properties..." button and select the "Filter" tab. An "empty" tab means, that there is no filter active. To activate a filter click on the top "funnel" icon. Now you can select one of "Enscript", "Pamphlet", "Image to PostScript Converter", "Page Selection/Ordering", "PDF Writer" or "Multiple Pages per Sheet". Should you construct and save any of your own filters with the help of the Filter Command Editor, it will automatically appear in the list.
Under the hood of the Filter Command Editor lies an XML file which is written from the configuration dialog. It holds the filter settings in a "tagged" data structure, which in turn serves to create the user interface for the control of the filter when called via the "kprinter" --> "Properties..." --> "Filter" dialog.
The active configuration for the enscript filter may be found on your system at $KDEDIR/share/apps/kdeprint/filters/enscript.xml. All other filter configurations are held in the same directory, in $KDEDIR/share/apps/kdeprint/filters/. Look at them to find out more about how they work. [There might be some other files in your $HOME/.kde3/share/apps/kdeprint/filters/ -- these are your personal copies, made when you edited the original ones; settings contained there override the system wide files].
The shipped enscript filter configuration (as most others) is limited to some of the most basic options:
But enscript is capable to do a lot more than what is configured at present with the KDEPrint Filter Command Editor. The KDEPrint Team has limited itself to the most important options. Look in the man page of enscript to see what more it supports from the command line:
All these commandline options can be translated into a GUI representation. Be creative! -- We are encouraging you to send in a more complete enscript.xml file for future enclosure in KDE distributions.
The "Filter Command Editor" principally works with any sensible external program. This program must be working from a command line and able to serve as a pre-filter to KDEPrint. Then the Filter Command Editor builds a GUI around it which can be plugged into KDEPrint. The usual commandline mode for such tools and utilities, with their various options, could normally only be used separately from KDEPrint, With the help of the Filter Command Editor they can now integrate nice and seamlessly into KDEPrint!
The Filter Command Editor allows you to modify or extend the shipped versions of KDEPrint filters on a per-user basis. Every user can construct his own filters, or have his own settings for the system-wide installed ones, without bothering other users.
(I should really show how to configure something useful, shouldn't I? No-one
will send me any money because of this hint, give-it-up!).
A command build with the help of the Filter Command Editor can be made to appear amongst the "Special Printers" in the kprinter drop-down list of available devices too.
For this to happen, go to the Print Manager (f.e. via "print:/manager/" as a konqueror URL), click on the "Add special (pseudo) printer" icon (the second from the left in the menu bar), tick the checkbox "Use command" and proceed to add your new command or select an existing filter from the drop-down list. Don't forget to fill in name, description and location fields.
Some fully working example filters (in fact, the most useful and commonly used) are shipping in the KDE-3 release packages.
The enscript frontend provides a GUI for the well-known ASCII-to-PostScript filter. This filter's options are normally specified on the commandline. Enscript produces PostScript page description output from otherwise unformatted ASCII text input. It commands options to determine page size, portrait or landscape mode, page frames, pretty headers and footers, font sizes and much more. The enscript filter is pre-configured to be run commanded through a dialog which controls some of its basic features. The output of this filter can then be run through another filter (for example the pamphlet filter) or send to the print subsystem, accompanied by the general KDEPrint job options.
The pamphlet filter enables a user to produce such advanced output even from simplex-only printers. It does so by re-arranging and imposing individual pages in a different order automatically, selecting odd and even pages to print in two separate passes through the simplex-only printer, flipping the paper in between the passes.. Another version of this filter can be used with a duplex-capable printer: here one just needs to select the duplex option that flips the page along its short edge and the pamphlets just need to be folded when the printer ejects them. The pamphlet filter relies on and combines the functions of "psbook" and "psnup" for its purpose. Most users will find the usage of these two utilities on the commandline too difficult. Using them through the KDEPrint "pamphlet filter" interface is a snap...
Configured filters (the ones you create yourself as well as the pre-built ones shipping with KDE-3.0.x) are accessible when printing with kprinter. Click on "Properties...", then on the "Filter" tab, and select a filter by clicking on the "funnel" icon. Some filters show a GUI to setup their options. Do so by first highlighting them and then clicking on the "hammer and wrench" icon at the bottom. -- Other items shown are:
Filters may be concatenated. The only condition is, that the output MIME-type of any filter will satisfy the input MIME-type requirements of the next filter in the chain. You can construct a filter chain "enscript --> pamphlet" which produces a pamphlet printout from any input text. It works because enscript takes text and produces a straight series of PostScript pages, which are taken by the pamphlet filter to impose and scale those pages to make up the final product (PostScript) that can be printed by any duplex-capable device.
You can even construct a chain "enscript --> page selection --> pamphlet". This chain allows you to print from a long ASCII or International text document only selected pages, but layed out as a pamphlet.
One KDE user, Paul Evans pevans@catholic.org, has started to build a few innovative and rather surprising applications around the Command Editor. The table lists his ideas and setups:
What he named it: | What it is good for: | What it requires: |
"No-name_email" | print emails without revealing names of recipients | bash (the shell) |
"ReadByViaVoice" | Read mail by "ViaVoice" special printer (setup actually used by friend of Paul suffering from dislexia, but can easily listen ViaVoice sound output) | ViaVoice (from IBM) and soundcard/speakers |
"PrintToWallpaper | convert KOrganizer output to bitmap dates on desktop | pstoimg |
"PrintToTranslator" | Not yet done, but neat: esp. if you pipe output to ViaVoice... | babelfish or similar |
"PrintToVector" | create an editable vector file (say, for Xfig) | pstoedit |
Maybe those suggestions will give you some idea about the flexibility of KDEPrint's inner architecture. Maybe they spark your own creativity now. If you have something to show us, tell so. We'll be happy to put your invention on our website.