The Apsfilter Documentation Document

Please note: This is about apsfilter-STABLE, the (stable) release version of apsfilter developement. Most of this documentation is still in an early state. If you feel something important is missing, if you find blatant typos or obsolete information, please contact the mailing-list at <apsfilter-doc@apsfilter.org>.

Overview


Preface

This document tries to inform you about all relevant aspects of apsfilter. Not many people like to read documentation, even fewer are actually willing to write it (trust me!). At least you were wise enough to have a quick look before doing any damage to your system, I hope.

FIXME: use fixed file locations in examples and explain them here or use path "variables"?


Introduction

Apsfilter (which means "Andreas' PostScript Filter" or "Another PostScript Filter" or even "Apsolute Filter" :) -- pick one you like) is an input filter suitable for most of the printer spoolers found on many UNIX-like operating systems. It is used all over the world in many different environments, from single user desktop computers to large-scale university networks.

The goal of apsfilter is to provide the user and the system administrator with a simple way to maintain, configure and use the printing services of the UNIX system. It's not targeted at one particular flavour or distribution of UNIX -- apsfilter tries to behave as friendly as possible in any environment.

The latest major version of apsfilter is 6.1.1 which was released in March 2001. There are also development snapshots and a CVS repository available. Point your web browser to the Apsfilter Homepage at www.apsfilter.org for a better overview of the latest releases.

The maintainer and copyright owner of apsfilter is Andreas Klemm <andreas@apsfilter.org>; he coordinates releases, merges patches from contributors and does stuff. Do not send bug reports or help requests to this email address -- there are mailing-lists that will save you (and us) the hassle of long fights with apsfilter.


Installation

Preparation

Before installing apsfilter, please make sure your system meets some basic requirements:

Your printer should basically work (i.e. it accepts data which has been sent directly to the interface) -- apsfilter can't fix hardware problems. Your system documentation (e.g. Printing-HOWTO, Linux documentation of the parport device, man pages to stty and setserial in case of a serial printer etc.) has more information on this topic.

FIXME: add *BSD information sources

Special note for users of older FreeBSD systems (and maybe others as well): to use the advanced features of apsfilter, the BSD-lpr program (not the LPRng version) needs the following patch:

Index: lpr.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/lpr/lpr/lpr.c,v
retrieving revision 1.32
diff -u -r1.32 lpr.c
--- lpr.c	2000/01/19 14:25:08	1.32
+++ lpr.c	2000/04/05 09:36:01
@@ -320,7 +320,7 @@
 	seteuid(uid);
 	card('H', host);
 	card('P', person);
-	if (hdr && !pp->no_header) {
+	if (hdr) {
 		if (jobname == NULL) {
 			if (argc == 0)
 				jobname = "stdin";
(This patch may have already been applied to newer version of lpr.)


Installation procedure

If your OS vendor is able to provide you with an apsfilter package of some kind, get that and install it the usual way.

Otherwise, login as the administrator (most probably root) and extract the apsfilter tarball in an appropriate directory (a common location is /usr/local/share).

        $ su - root
        Password:
        # cd /usr/local/share
either  # gzip -cd /path/to/apsfilter-X.Y.Z.tar.gz | tar xf -
                (if you downloaded the gzip'ped version)
or      # bzip2 -cd /path/to/apsfilter-X.Y.Z.tar.bz2 | tar xf -
                (if you downloaded the bzip'ped version)
        # cd apsfilter

You can optionally copy the contributed uniprint profiles into your ghostscript "lib" directory -- if you don't intend to use the uniprint driver, or use a different printer, these won't help you. Recent packages of ghostscript may already contain them.

        # cp uniprint/*.upp /path/to/ghostscript/version/lib

If your /bin/sh shell is not capable of the POSIX features that apsfilter relies on, you'll have to change the path in the first lines of bin/apsfilter and SETUP to point to a "real" shell. Your system administrator should be able to help you.

Note: The Makefile in the apsfilter directory is only used by the FreeBSD ports collection. Other systems will most likely get an error message like *** missing separator. But you have already tried that, haven't you? :^)

Note: The installation procedure is bound to be changed in the near future.


Setup

Setting up the printers is done via the SETUP script in the apsfilter installation directory (in our example this would be /usr/local/share/apsfilter). If you are paranoid, it is probably safer to make sure the lpd daemon is not running while you set up your printers.

        # /usr/local/share/apsfilter/SETUP

The SETUP program more or less guides you through the whole process; just answer the questions to your best knowledge:

The configuration directory will be used to store global and printer specific configuration files (some in their own subdirectory). It's probably a good idea to enter the path to a directory which will be used exclusively by apsfilter (like in the examples shown on the same screen).

Some installations of lpd tend to have problems with the correct spool dir owner/group/permission settings; this might affect special apsfilter features. In case you use LPRng, you can call the checkpc program which is able to reset all relevant settings to sane defaults that are guaranteed to work. (SETUP does this for each printer after installation.)

With SETUP, you can either overwrite the previous printer entries in /etc/printcap that are used by apsfilter or just add one or more printers. In any case, a backup copy will be stored as /etc/printcap.old.

Just to make sure you are using the correct ghostscript executable, you can take a look at the devices that are supported by your gs (use <d> in the main menu). Many of these will probably be devices that actually produce bitmap images, so they are not very useful with printers.

Choosing the right printer driver is important for smooth operation of apsfilter:

Several printers can be used with more than one driver; you can choose one after another, print the test page and compare the visual quality and even the time needed before actually installing the printer.

If you have a printer which is not supported by any of the drivers, you might want to try a driver that knows similar compatible devices; some fine-tuning may be necessary. However, if you already have a driver for your printer which just doesn't show up in any of the lists, you'll have to install some other driver and change the appropriate configuration file by hand later.

The printer interface decides how to physically connect to the printer. For home installations, this will most probably be a parallel or USB connection (serial printers are becoming rare, but can be used as well). For networks, you can use UNIX-style connections via the lpd on the printer server, samba for printing to Windows servers or AppleTalk for Macs.

The paper size setting is the default for any further printing attempts, but it's possible to adjust it on the command line later on. You must set this.

Some printer drivers don't support any other resolution than their default value; please consult the appropriate documentation.

If you think your settings are correct, you can install the printer (with <i>); you will then be asked if you want to install a "raw" printer queue. This provides you with the possibility to directly print the data without any changes or filtering (you can also enable this on the command line with each print job, so you probably only need the "raw" printer if the command line is not always available, e.g. if you get print requests from over the network). You definitely don't need more than one "raw" entry per physical printer.

The printer queue name is the name that you will use to specify a printer other than the default. Use short and simple names that clearly let the users distinguish between the printers; using just letters and numbers is preferred.

Each printer will get its own spool directory (hopefully with the correct permissions set) and configuration subdirectory which will contain all necessary information that apsfilter needs to properly control the printer.

After that you are returned to the main menu so that you can install more printers or finish the setup.

To complete the setup, you'll have to signal the printer spooler that there's a new printcap file to be used:

Note: The setup procedure is bound to be changed in the near future.


Usage

Normal operation

If you try to call the apsfilter script directly, you will get an error message by email and/or on the console -- why doesn't that ?$#!@ thing work?

Well, that's just not the way printer filters are used. Apsfilter links itself into the lpd mechanism for print job processing via the /etc/printcap database. For every print job, the printer daemon prepares the data, gathers some additional information and calls the filter with a couple of parameters (which were missing when you tried to call apsfilter directly).

Then apsfilter processes the input data stream according to the configuration settings and basically spews the printer data out (but there's lots of magic in between).

So the user doesn't actually get in touch with apsfilter, but rather tells the printer daemon via lpr that he wants to print something. However, apsfilter provides some extensions to the plain printing procedure that enables the user to influence the visual appearance of the printout etc.

The way apsfilter gets these additional information depends on the type of spooler which is installed on the system:

Apsfilter options can be separated by ":" or ","; LPRng can also take more than one "-Z" or "-o" block (and will effectively concatenate them).

To find out which options apsfilter understands, have a look at the configuration section (because these options are actually temporary on-the-fly configuration changes).


Special features

Apsfilter is able to extend the normal printer spooler operation with non-standard features that provide some comfort to the user.

Fake duplex printing

If your printer is not able to handle duplex printing by itself (most inkjets can't do it), apsfilter can "fake" it for you. When you use the command line option "duplex", your file will be printed this way:

  1. all necessary pre-processing, conversion etc. will be performed as usual
  2. the even pages of the resulting PostScript code are extracted and printed (the number of even pages is always less or equal to the number of odd pages; this way, all sheets will be re-used)
  3. apsfilter sends you an email which tells you to flip the sheets and put them back in
  4. you also get some more-or-less secret key ("password") with the email which you should echo into an internal communication file (a "named pipe" for the experts) when the paper and the printer is ready
  5. the odd pages are printed on the backsides of the even pages

Please note:

Duplex printing (real or fake) can be disabled by setting the DISABLE_DUPLEX variable to a non-empty value.

Fast multiple copies

Almost all printer spoolers offer the possibility to print multiple copies of a document without having to enter the print command multiple times. However, from apsfilter's point of view, there is no difference -- it simply gets the same request over and over again.

With the "copies=N" option you can print N copies of the same document, but much faster. Instead of performing all the pre-processing and rendering stages again for each request, apsfilter does the hard work once, then prints the resulting "raw" printer data N times. (This also works with the fake duplex mode.)

If this conflicts with other services on your system (e.g. accounting), you can disable it by setting MAXCOPIES=1 in one of the configuration files.


Configuration

Configuring apsfilter can be done in two separate ways: either the administrator supplies specific values to configuration variables, or the user provides options to the lpr or lp program. Command line options usually have greater priority, unless some service has been disabled entirely (e.g. duplex printing).

Configuration files

Apsfilter uses a bunch of configuration files:

All of these files are ordinary shell scripts. Since the printer daemon (and as a result also apsfilter) may run with high privileges, the user supplied configuration normally is not used. As usual with shell scripts, any environment variable can be changed, any program can be called -- so the apsfilter effective user id (which may even be root) can cause quite some damage.

The following variables directly affect apsfilter; although decent default values for most of these are provided, you should review them anyway.

variablemeaning
PATHshell search path; should be as restrictive as possible
NOTIFYuser name of the person in charge for printer errors
TMPDIRdirectory for temporary files; apsfilter actually creates a subdirectory of its own for better security
USE_USER_CODEif set, enables the user specific file ~USER/.apsfilter/apsfilterrc.QUEUE as a configuration source
DANGEROUS! -- you probably don't want to set it (it is unset by default)
TEXINPUTSsearch path for dvips (PostScript pictures etc.)
PRINT_DVIcustom "DVI to printer language" filter (stdin->stdout); if empty, dvips (with possible rendering by ghostscript) will be used
HAVE_MAKETEXPKif set, enables dvips to create fonts on the fly (this functionality is broken on more systems than you would imagine)
DVIPS_RES_DorPdvips resolution switch; should be "-D" or "-P" (consult your dvips man page)
GS_FONTPATH
GS_LIB
environment variables for gs, used to find fonts and support PostScript files (the ghostscript documentation has more information on this)
RAW_PROLOGUE
RAW_EPILOGUE
printf style escape sequences to be used before/after a "raw" print job
GS_FEATURESbasic features for ghostscript; this variable can be extended with command line options
GS_RESOLrendering resolution for ghostscript
PS_INITghostscript initialisation file
PS_EXITghostscript "cleanup" file
PPA_OPTSbasic features for pnm2ppa; this variable can be extended with command line options
COLORcontrol color or b/w printing, should be "color", "colour" or "mono" (may not work with all printer/driver combinations)
HARDWARE_DUPLEXset this if your printer and the driver can handle duplex printing by themselves (otherwise it can be "faked")
Note: the "pswrite" driver does not preserve the duplex sequences
DISABLE_DUPLEXset this to completely forbid duplex printing; must be set on a network print server that operates printers which would need "fake" duplexing
DUPLEXset this if you always want duplex prints
BINDINGwhich edge of the paper the binding should be (one of "short", "long")
PAPERTRAYinteger value to select the correct paper feed tray
MAXCOPIESmaximum numbers of copies created with apsfilter's internal copying mechanism
ASCII_FILTERfilter to convert text files to PostScript (one of "a2ps", "mpage", "enscript"), or to directly print text files with possible charset and end-of-line conversion ("recode")
A2PS_BASICbasic features for a2ps
A2PS_PAPERSIZEoverride the paper size for use with a2ps
A2PS_OPTSoverride the complete a2ps command line
MPAGE_BASIC
MPAGE_PAPERSIZE
MPAGE_OPTS
the same for mpage
ENSCRIPT_BASIC
ENSCRIPT_PAPERSIZE
ENSCRIPT_OPTS
the same for enscript
RECODE_OPTSoverride the complete recode command line
ASCII_HEADERset this if you want header lines in the formatted text output (no effect with "recode")
ASCII_BORDERset this if you want borders in the formatted text output (no effect with "recode")
PS_NUPmultiple pages per sheet (must be 1, 2, 4, 8)
ASCII_PPSthe same, but just for text (no effect with "recode")
LANDSCAPEset this if you want landscape orientation
ASCII_LANDSCAPEthe same, but just for text (no effect with "recode")
HTML2PS_OPTSoverride the complete html2ps command line
PS_BOOKoutput pages in "book" format
PS_UTILSadditional PostScript->PostScript filter
the following options are created by SETUP
PRINTERspecifies the driver (and for some drivers the printer model as well)
PAPERSIZEthe paper size used for practically every program that needs to handle PostScript code
METHODeither "auto" (automatic file conversion), "ascii" (treat everything as text) or "raw" (pass-through mode)
RESOLUTIONthe printing resolution; can be overridden for ghostscript by GS_RESOL

The template apsfilterrc file is the definite source for these configuration possibilities, and shows the default value as well. There are more variables that can affect apsfilter's behaviour; see the next section.


Command line options

First of all, all command line options are case insensitive. So here are the options that work independently of the driver, plus the configuration variable that they affect.

optionmeaningvariable
ascii / auto / rawprinting methodMETHOD
a3 / a4 / legal / letter / ledgerpaper sizePAPERSIZE
color / colour / monocontrol color or b/w printingCOLOR
a2ps / mpage / enscript / recodeset the text file filter ASCII_FILTER
tray0 ... tray9paper feed tray numberPAPERTRAY
header / noheaderwhether you want headers with your text prints ASCII_HEADER
border / noborderwhether you want borders with your text prints ASCII_BORDER
1pps / 2pps / 4pps / 8ppspages per sheetPS_NUP, ASCII_PPS
landscape / portraitpaper orientationLANDSCAPE, ASCII_LANDSCAPE
bookoutput pages in "book" formatPS_BOOK, PS_NUP, ASCII_PPS, DUPLEX, BINDING
duplex / simplexwhether to use duplex modeDUPLEX
shortbind / longbindpaper binding edgeBINDING
copies=Nnumber of copiesCOPIES

The following command line options are driver specific; different drivers for the same printer model may or may not support them.

stcolor

optionmeaningvariable
low / medium / highprinting resolution of 180 / 360 / 720dpi GS_RESOL
uniuse unidirectional outputGS_FEATURES
microweave / noweave / softweaveweaving modeGS_FEATURES
gscmyk / gsmono / gsrgb / fsmono / fsrgb / fsx4 / fscmyk / hscmyk / fs2dithering algorithmGS_FEATURES
1bpp / 3bpp / 8bpp / 16bpp / 24bpp / 30bpp / 32bppcolor depth GS_FEATURES
flag0use "-dFlag0"GS_FEATURES
plain / runlength / deltarowcompression algorithmGS_FEATURES

cdj500, pjtest, declj250

optionmeaningvariable
low / medium / highprinting resolution of 150 / 300 / 600dpi GS_RESOL
plain / bond / special / glossy / transparencypaper type GS_FEATURES
draft / normal / presentationoutput qualityGS_FEATURES
1bpp / 3bpp / 8bpp / 16bpp / 24bppcolor depthGS_FEATURES

cdj550

optionmeaningvariable
32bppcolor depth GS_FEATURES
This driver also knows the cdj500 options.

cdj880

optionmeaningvariable
30bppcolor depth GS_FEATURES
This driver also knows the cdj550 options.

cdj670, cdj850, cdj890, cdj1600, cdj970

optionmeaningvariable
reton / retoffwhether to use C-RET (FIXME: C-RET = color correction?)GS_FEATURES
These drivers also know the cdj880 options.

pjxl300, pjxltest

optionmeaningvariable
low / medium / highprinting resolution of 150 / 300 / 600dpi GS_RESOL
plain / bond / special / glossy / transparencypaper type GS_FEATURES
draft / normal / presentationoutput qualityGS_FEATURES
render0 ... render10rendering typeGS_FEATURES
1bpp / 3bpp / 8bpp / 16bpp / 24bpp / 32bppcolor depth GS_FEATURES

bjc600, bjc800

optionmeaningvariable
low / medium / highprinting resolution of 150 / 300 / 600dpi GS_RESOL
low / draft / normal / presentationprinting quality GS_FEATURES
plain / coated / transparency / envelope / card / othermedia typeGS_FEATURES
1bpp / 4bpp / 8bpp / 16bpp / 24bpp / 32bppcolor depth GS_FEATURES

hpdj, pcl3

optionmeaningvariable
low / medium / highprinting resolution of 150 / 300 / 600dpi GS_RESOL
500 / 500c / 510 / 520 / 540 / 550c / 560c / 850c / 855c / unspec printer modelPRINTER
mono / cmy / cmyk / cmy+kcolor modeCOLOR, GS_FEATURES
draft / normal / presentationprinting qualityGS_FEATURES
plain / bond / premium / glossy / transparency / photomedia type GS_FEATURES

pnm2ppa

optionmeaningvariable
uni / biunidirectional/bidirectional printingPPA_OPTS
ecoeconomy modePPA_OPTS
noblackdo not use the black ink cartridgePPA_OPTS

If your printer/driver does not have any options defined yet, or if you want more/different options for a specific driver, please don't hesitate to contact us at <apsfilter-hackers@apsfilter.org>.


FAQ

This section covers the most frequently asked questions, or what we think should be questions frequently asked if they were asked at all :)

If you dare to ask one of this questions on the mailing-lists, you will be laughed at!

Apsfilter error messages

Q: "can't find apsfilter basedir"
A: The SETUP (besides other things) creates a link /usr/local/etc/apsfilter/basedir that points to the actual directory where apsfilter was installed. This link has been either mangled or deleted entirely. Try to run SETUP again.

Q: "can't find configuration"
A: The only configuration file that positively has to be found for each QUEUE is /usr/local/etc/apsfilter/QUEUE/apsfilterrc, because this file defines the most important variables (driver and printer model, paper size, printing method). SETUP should have created that file... strange.

Q: "unsupported file type 'foobar'"
A: The file command has identified your input file, but apsfilter doesn't know how to print it. If you know a converter for this type of file which works on the command line (preferably to PostScript or PNM, but others might work as well), please contact us at <apsfilter-hackers@apsfilter.org>.

Q: "missing 'foo'; can't convert file type 'bar'"
A: In this case apsfilter knows the file type, but is unable to locate any filter which may be used for further processing. This might be solved by adjusting the PATH setting in the global apsfilterrc, but most likely you don't have a converter for that type installed. For several file formats there's more than one possible filter (not just the one that is called "missing").

Q: "invalid method 'foobar'"
A: This is another "can't happen" error, because the only chance to get this error message is when some person fiddled with the printer queue specific apsfilterrc file -- and it surely wasn't you, was it? Anyway, the METHOD setting must be one of "auto" (this is probably what you want), "ascii" or "raw".

Q: "can't determine the lpd spool directory"
A: This error may have two different reasons:

  1. You want to print directly to a remote printer queue, but your spooler can't handle it. In this case you either can install LPRng or you need a "bounce queue" (see below).
  2. You are using a BSD style spooler, but have removed the "accounting file" specification in /etc/printcap (the ":af=..." line). Even if you don't want accounting, you must leave that line in there, because that's the only chance for apsfilter to get hold of the spool directory location (which is also the directory the accounting file is in).

Q: "error creating directory for temporary files"
A: The temporary file directory TMPDIR used by apsfilter can be set in apsfilterrc; the default is /tmp. The permission bits of this directory should be 1777 (rwxrwxrwt), so that apsfilter can create its own subdirectory which will be used for temporary files.

Another reason for this error is a denial-of-service effect which occurs if the name apsfilter$$ (where $$ is the process ID) is already used in TMPDIR and the mktemp program cannot be found. If you install mktemp, you most likely won't ever see this error message again.

Note: In this case, apsfilter exits with a non-fatal error code. Depending on your printer spooler type, lpd might want to retry to print the file, since the error condition is not persistent (e.g. the next run will have a different $$ value).

Q: "missing 'foo'; can't unpack file type 'bar'"
A: The file you wanted to print was compressed, but the decompressing tool was not found in the PATH. Install it, or adjust the PATH setting in the global apsfilterrc configuration file.

Q: "apsfilter warning: html2ps needs gs for DSC compliance"
A: When converting HTML files to PostScript, the html2ps converter relies on ghostscript to create DSC compliant PostScript documents; this is needed for any further processing via the psutils (n-up printing, duplex etc.). The gs executable was not found in the PATH; however, since it might be okay to create non-DSC documents, apsfilter just prints a warning to the log/status file.

Note: Since html2ps can have its own PATH setting in the configuration file html2psrc, this warning may even be unnecessary.

Q: "apsfilter warning: duplex fifo couldn't be created"
A: For fake duplex printing to work, apsfilter needs to set up a named pipe (a.k.a. fifo) which enables to user to send the release-key to apsfilter. This pipe/fifo is created with the mkfifo command, which failed in this case -- apsfilter then prints the file in simplex mode.


Printing errors

Q: I just have set up the printers, but the names are not recognized by my spooler software!
A: Are you sure you have restarted the printer daemon? As SETUP alters the central configuration file /etc/printcap, the spooler must be told to use the new version. The setup instructions tell you what to do.

Q: The spooler takes the input file, but there's nothing coming out of the printer.
A: Are you sure you're talking to the correct printer? If your /etc/printcap already contained a printer called lp, it's likely that you tried to use that printer queue. Some lpd packages "feature" a sample lp entry in printcap which is suitable for a generic, mostly text-only printer. Try using the "-P my_printer_name" command line option to lpr (for the lp interface it's "-d my_printer_name"). If that works, either set the environment variable PRINTER=my_printer_name or change /etc/printcap manually, so that lp is an alias for the correct queue.

However, this could also be a processing error, maybe even a syntax error in the filter script. Please have a look at the help section to find out how to enable debugging. If the debug output is not helpful to you, please send us a bug report.

Q: I want to print to a remote printer, but my spooler doesn't allow input filters for remote printers in /etc/printcap.
A: This might be solved by using a so-called "bounce queue". You must edit /etc/printcap to change the :lp= entry for the printer to be :lp=/dev/null:; then you create a simple text file called lpr.conf in the appropriate configuration directory, e.g. /usr/local/etc/apsfilter/QUEUE/, that consists just of one line:

	REMOTE_NAME=remoteprinter@remotehost.somedomain
If the printer is on the same host, you can leave out the trailing @remotehost.somedomain part. Remember to restart the daemon in any case.

Q: Why doesn't apsfilter find the conversion programs? I know that they are installed!
A: By default apsfilter uses a restricted PATH for security reasons. You can alter the PATH in /usr/local/etc/apsfilter/apsfilterrc (global) or in the printer specific apsfilterrc.

Q: Why is the resolution for dvips wrong?
A: For whatever reason, there are different dvips version out there which use either "-D" or "-P" as the command line switch to set the resolution. Consult your dvips manpage and set DVIPS_RES_DorP in the main configuration file.

Q: I get "permission denied" errors for some file cf...!
A: That's a classic FAQ :) Far too many lpd installations suffer from wrong permissions or non-matching user/group ID settings which prevent apsfilter from reading that control file. All I can say is: LPRng doesn't have that problem.

Q: For some files I want to print, there are error messages regarding "DSC" showing up in the log. What's that?
A: DSC (Document Structuring Conventions) is the format specification for PostScript data files. These error messages probably say that the application which produces the PostScript data is buggy. You may be able to fix that by saving the PostScript data to a file first, then using the "fixps" tool (or some variant) to get it working.

Q: Why can't I print DVI/HTML/Sketch/FIG files with embedded images etc.?
A: That depends on the file format and the way the images are embedded. For inline images, i.e. images that are literally included in the file, there shouldn't be any problems. If the image is referenced by a filename, it must not only be found but it must also be accessible.

Relative pathnames are very hard for the filter to expand, since it must know a directory (or a set of directories) to search in. Absolute pathnames are more pleasant, but you still have to make sure that the referenced file is readable by anyone and every directory down the path is executable by anyone.

The easiest way to print the file correctly might be to convert it to PostScript manually (maybe the application has an export option, otherwise have a look at the apsfilter script to get a hint what to do) and then print it the usual way.


Tuning

Q: My printer needs special treatment to reset it before any print job, set the codepage, enable the correct end-of-line mode, add an extra formfeed afterwards etc.
A: Grab your printer documentation to look for the escape sequences needed and enter these into the configuration variables RAW_PROLOGUE and RAW_EPILOGUE (remember to use octal values). To send a reset sequence of "ESC c" before and an additional formfeed after the raw print job, use

	RAW_PROLOGUE='\033c'
	RAW_EPILOGUE='\014'

You can also set command line options for recode in the variable RECODE_OPTS if you want fast text listings; a simple "LF -> CR+LF" conversion using the latin1 charset would be enabled by

	RECODE_OPTS='l1..l1/crlf'

Q: I have a PostScript Level 1 printer. How can I tell apsfilter to produce correct output?
A: You must use the special PSgs_* drivers which use the "pswrite" and "psgray" ghostscript devices. Then add "-dLanguageLevel=1" to the GS_FEATURES variable for that printer.

Q: Printing program listings etc. is dog slow.
A: If you use a2ps (the default), mpage or enscript to print text files, these are converted to PostScript first. For plain text printings you can use recode as the filter (either set ASCII_FILTER=recode or use the "recode" command line option). However, you lose all the spiffy features like borders, headers, multiple pages per sheet and fake duplex mode.

Q: I want to print the source code of some PostScript, HTML, Sketch, ... file, but all I get is the formatted output.
A: You have to tell apsfilter not to automagically convert the file, but rather treat is as normal text; use the "ascii" command line option.

Q: The page margins are not correct. / The printout is shifted in one direction.
A: Although this is not actually an apsfilter problem, here are some hints:

Q: Why are parts of the page missing on my PostScript printer?
A: Pages in higher resolutions or with complex content need plenty of RAM to be rendered. For some printers the standard amount of memory which is built in just isn't enough. You can either put more RAM into your printer or reduce the rendering resolution (to probably half the amount). Using the special PSgs_* devices might help as well.

Q: When I print more than one file at a time, the headers for text files are wrong; they still show the name of the first file!
A: This ever-annoying problem only occurs with BSD spoolers which just don't give enough information about a print job to the filter. The solution is to install LPRng, or print just one file at a time, or disable headers completely.

Q: Why is my DVI file messed up? It should be in landscape mode, but the right border is chopped off!
A: The problem is that dvips doesn't know if the file is in landscape mode or not. You have to explicitely use the "landscape" command line option.

Q: My printer/driver can only produce grayscale output. So it doesn't matter what value COLOR has, right?
A: Wrong. For example, a2ps uses colors to render headers, do pretty-printing etc. These colors look different on a grayscale printer than the gray levels used when COLOR=mono is set. Additionally, some converters use special algorithms when they are told to produce grayscale output; this might improve the result. They usually run faster in this mode, as well.


Links

The first and most important link is of course The Apsfilter Homepage. This is the definite source of information about apsfilter, most importantly the download section.

To keep up with the latest apsfilter changes, you can use the CVS server as decribed here or browse the repository.

Software packages

If you experience problems with the plain BSD spooler, you might want to check out LPRng which has many more features, is more secure and flexible and less buggy.

It's a good idea to keep up with latest releases of ghostscript, be it the free GNU version version or the commercial one.

External drivers for ghostscript are available:

The following packages are not supported directly by apsfilter, but they can be used with the help of bounce queues which are tricked into thinking there's a PostScript printer, but are redirected to the real printer queue.

If you are unlucky to own a PPA printer by Hewlett-Packard, you must install the pnm2ppa conversion tool.

If you want to print bitmap images directly, you must install one of the packages that provide the right filters: ImageMagick, XnView or the netpbm tools. These differ in the number of supported file formats, however.

For easy manipulation of PostScript files, the psutils package will provide you with the necessary tools.

Text-to-Postscript converters are available here: a2ps, mpage, enscript. For fast text output and charset conversion, you can use recode.

Here's a list of other known conversion tools:

Further information

A good overview of printers, drivers and printing systems can be found on www.linuxprinting.org. Don't be mislead by the name, most of the information is valid on any UNIX-like system.

The Linux Printing HOWTO is a must read for all Linux administrators (and probably others as well) -- preferably before you try to set up your printer. Users might also profit from the Linux Printing Usage HOWTO.


Help

You help us

That's not what you wanted to read, is it? Anyway, we are in a constant need of bug reports, new ideas, suggestions -- but also "real value" support in form of hardware or software donations, job offerings or just pure hard ca$h. So check out this to get there :^)

We help you

The first step to solve any apsfilter problems is to make sure it actually is not some kind of other defect on your system (hardware, spooler software, power lines, ...). If you are absolutely sure that your problem is not already covered in the FAQ or in other parts of this documentation, read on.

There's also a mailing-lists archive which you can browse and search. Maybe your problem has already been solved, or even classified as a feature ;)

Reporting bugs

To prepare a bug report, it's absolutely necessary to create a log of the failed printing attempt. Note: LPRng users should enable the filter_stderr_to_status_file option in /etc/lpd.conf, otherwise the log will be very hard to read.

First edit the /usr/local/share/apsfilter/bin/apsfilter script and search for occurences of "[DEBUG]":

(Remember to change everything back later on, otherwise the printer will continue to produce debugging output.)

After that, print the file again (try to take the same steps as before when the print attempt failed). Then there should be a log of the last apsfilter session in the log or status file which resides in the spool directory of the printer queue you used (usually /var/spool/lpd/QUEUE/).

The log shows a detailed trace of what apsfilter tried to do; if that doesn't help you, just save the file for inclusion into the bug report.

Please follow these instructions to create a bug report that will actually be meaningful to everyone who tries to help you (did I mention that we don't get any money for that?).

A decent bug report contains:

You might wonder if that is really necessary, but since there are so many factors that might be the cause of the problem, a bug report like this will be the fastest way to find the error.

Now that you have assembled all the information -- where to send it? It is basically a very bad idea to send it directly to one of the maintainers (not even with CC). The people who can actually help you read the mailing-lists that have been established for just this purpose:

We hope that we can help you!

General help

If you need general help with apsfilter (i.e. if it's not even possible to produce a bug report), there are some more mailing-lists available:

There are also two read-only public mailing-lists:

The lists are controlled by majordomo; to get more information, send an email to <majordomo@apsfilter.org> with the subject help.

To subscribe to a mailing-list, send an email to <majordomo@apsfilter.org> with the body subscribe apsfilter-xyz.


ToDo

Several ideas have already been collected, but nobody has started to implement them -- either because it would require too much work, or the demand is just too low, or there's an ongoing discussion. More ideas should be sent to <apsfilter-hackers@apsfilter.org>.


Apsfilter Prints So Fine, It Leads To Extraordinary Results

This document is © 2001 Michael Loßin <phallobst@web.de>
distribution of this file is permitted under the regulations of the GPL