Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jan 1998 18:58:12 -0800 (PST)
From:      papowell@astart.com
To:        chuckr@glue.umd.edu, questions@FreeBSD.ORG
Subject:   LPRng and FreeBSD
Message-ID:  <199801100258.SAA05846@astart4.astart.com>

next in thread | raw e-mail | index | archive | help
> > From chuckr@glue.umd.edu Tue Dec 30 18:50:37 1997
> > Date: Tue, 30 Dec 1997 21:37:58 -0500 (EST)
> > From: Chuck Robey <chuckr@glue.umd.edu>
> > To: Patrick Powell <papowell@astart2.astart.com>
> > cc: questions@FreeBSD.ORG
> > Subject: Re: Free BSD - have software for distribution
> >
> > 3) Are you aware of our port of apsfilter?  I think in your post, you
>
> Yes,  in fact I recommend its use with LPRng!  I have even redone some of
> the LPRng interfaces to make it easier to use with apsfilter.

I was looking at the apsfilter distribution in LPRng, and suddenly
realized that there was room for some slight,  umm...,  improvements.
You will now be please to find Son of APSFILTER available for your
enjoyment.

Also,  there will be a 'setup' script in the next release of LPRng
that will largely automate the setting up of printcap entries
(I hope!).  This may reiterate what you already have,  but it provides
some assistance for the LPRng specific capabilities.

See:
  ftp://ftp.astart.com/pub/LPRng/FILTERS/apsfilter_LPRng.1.1.1.tgz

Patrick Powell                 Astart Technologies,
papowell@astart.com            9475 Chesapeake Drive, Suite D,
Network and System             San Diego, CA 92123
  Consulting                   619-874-6543 FAX 619-279-8424 
LPRng - Print Spooler (http://www.astart.com)

Here is the README from the distribution:

LPRng apsfilter
  Version 1.1
  Patrick Powell <papowell@astart.com>

 Inspired by the
 apsfilter - Line Printer Input Filter
   by Andreas Klemm <andreas@knobel.gun.de>
   co-author: Thomas Bueschgens <sledge@hammer.oche.de>

Express Installation Instructions
    ./configure
    make clean install
  To test the apsfilter:
    ./test.aspfilter
  To finish the setup, generate the printcaps, etc:
    setup
  Read the rest of this document,  update the /etc/printcap and install
    the apsfilter.conf file in the appropriate location.

You will need:

  a2ps (Text to PostScript converter), at least version 4.9.9
    The main distribution point is:
      http://www-inf.enst.fr/~demaille/a2ps
    There are multiple mirror sites.

  GhostScript (Developed using Aladdin GhostScript Version 5.10
    The main distribution point is:
	  http://www.cs.wisc.edu/~ghost/
    There are multipel mirror sites.

  The dvips programs,  which can be obtained from a TeX distribution.
    I strongly recommend either using a canned TeX distribution or
    using the teTeX distribution.  The primary site is:

      ftp://sunsite.informatik.rwth-aachen.de:/pub/comp/tex/teTeX

	  Mirror sites:
	  ftp://sunsite.unc.edu/pub/Linux/apps/tex/teTeX/distrib
	  ftp://ftp.dante.de/tex-archive/systems/unix/teTeX
	  ftp://ftp.tex.ac.uk/tex-archive/systems/unix/teTeX

   The pnm (portable anymap) package.  Distributed with X11R5/X11R6.

Overview

This filter is meant to be used with an LPRng printcap file of the
following form (this will be generated by the 'setup' script):

pr_ascii|PS_300dpi ascii mono
 :qq:lp=lp1@astart4.astart.com
 :force_queuename=aps-PS_300dpi-letter-ascii-mono
#
pr_raw|PS_300dpi raw
 :qq:lp=lp1@astart4.astart.com
 :force_queuename=aps-PS_300dpi-letter-raw
#
pr_auto|pr|PS_300dpi auto mono
 :qq:lp=lp1@astart4.astart.com
 :force_queuename=aps-PS_300dpi-letter-auto-mono
#
lp1|PS_300dpi
 :qq:lp=/dev/lp0:server
 :sd=/usr/spool/lp1
 :lf=log:af=acct
 :if=/usr/local/lib/filters/apsfilter
 :direct_read:mx#0:sh:sf

# OR THE FOLLOWING (see below)
lp2:qq:lp=/dev/lp0
 :sd=/usr/spool/lp2
 :if=/usr/local/lib/filters/apsfilter -Tdevice=aps-PS_300dpi-letter-auto-color
 :direct_read:mx#0:sh:sf

The trick behind all of this is the
 :force_queuename=aps-PS_300dpi-letter-auto-mono
printcap entry.  This causes
 Qaps-PS_300dpi-letter-auto-mono
to be placed in the print job control file,  and the print filter
(i.e. - if=/path of=/path programs will be invoked with:
  /path -Q aps-PS_300dpi-letter-auto-mono

The apsfilter program then chops this string up to determine the
device (PS_300 is PostScript 300 dpi), paper size (letter), method
of determining type of job, and color or mono printer.
The raw, text, and auto indicate no conversion, ascii to PS conversion,
and automatic analysis using the file() program.

The -Tdevice=aps-... can be used to explicitly provide a specifier value.

DETAILS:

The apsfilter program is actually a Perl Script.  It sets up a pipe
from the STDIN to STDOUT that will convert the input file (print job)
into output compatible with the specfied output device.
The chain of filters which process the input file are:

   $decompress | $to_ps | $gs | $commprog

The device $specifier is the ugly looking string passed as the -Q
or -Tdevice=... command line option to the filter.

Example: aps-PS_300dpi-letter-auto-mono

Value        Variable
aps          (ignored)
PS_300dpi  = $device
letter     = $pagesize
auto       = $style
mono       = $color

The values for $decompress, $to_ps, $gs, and $commprog are determined
as follows:

1. if $style is raw,  no processing is done, i.e. - the chain is:
    $commprog
2. if $style is ascii, then the input file is ascii, and the $a2ps
   program is used as the $to_ps value:

                $a2ps | $gs | $commprog

3. if $style is auto,  then the 'file(1)' utility is invoked to
   determine if the file is compressed, and then the actual
   (uncompressed) file type. Based on the file type,  the $to_ps
   value is set. The chain is:

		$decompress | $to_ps | $gs | $commprog

While this is a reasonable approach,  it turns out that there are some
things that need to be configured on a per-system and/or per printer basis.
In order to do this,  the global (/usr/local/etc/apsfilter.conf by default)
and local (./apsfilter.conf) default files are read by the program.
The conf files have the following format:

# apsfilter configuration file
#PATH=/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin
#
# communications program
# commprog = /bin/cat -
# a2ps = a2ps -q -R -1 -m -B
rewindstdin = /usr/local/bin/rewindstdin
lp\.printer = aps-laserjet-letter-auto-mono
lp\.allow_pcl = 1
lp\.res = 600

NOTE:  the setup script will generate a apsfilter.conf file;
this file should be copied to the printer spool directory or
to the /usr/local/etc/apsfilter.conf.

The PATH, commprog, rewindstdin, and a2ps entries provide override
values for the PATH environment variable and the $a2ps and $commprog
filters.  Early versions of Perl did not support the sysseek
function; the rewindstdin program provides this functionality.

The other entries are more interesting.  Each corresponds to
a regular expression that is used to match one or more values during
the execution of the apsfilter program.

1. At the start of the program,  the -P $printer option value is
   used to form "$printer.printer";  a search is done for a matching
   key in the configuration file and used to set the $specifier
   value.  For example,  in the above example, printer -P lp would
   form lp.printer,  and this would match the lp\.printer regular
   expression and the $specifier value then be
   aps-laserjet-letter-auto-mono.

2. If no $specifier was found in step 1, then the -Q $opt_Q option
   value is used to form $opt_Q.printer and a similar lookup is
   done;  the resulting key match and value is used to set the
   $specifier value.

3. If no $specifier was found in steps 1 and 2, then the $opt_Q
   value (if any) is used as the $specifier value.

4. If no $specifier is found,  then an error is reported.

5. The $specifier value is split up as described above,
   and $device field is then used in further searches.

6. The configuration information is then searched for (in order)

   $printer.commprog  - communications program
   $printer.allow_pcl - 0 to disable PCL printing, 1 to enable
   $printer.res       - device resolution (default 300dpi)
   $printer.a2ps      - device a2ps command if necessary
   $device.commprog   - communications program
   $device.allow_pcl  - 0 to disable PCL printing, 1 to enable
   $device.res        - device resolution (default 300dpi)
   $device.a2ps       - device a2ps command if necessary

7. The desperate hacker is, of course, referred to the apsfilter
   source code,  where there are other little gems buried in the
   program text which will aid and assist in dealing with those
   horrible printers which do not fall into this very simple model.

Rewind STDIN Program

In order to use the 'file(1)' program,  STDIN must be rewound.
Unfortunately,  early versions of PERL do not support the sysseek()
function, and the rewindstdin program is needed.

Setup Program

The setup program is used to generate a sample printcap entry that
can be used to install the apsfilter.

The output of the program will be a printcap.template file
and an apsfilter.conf file.

The printcap.template file should be merged into the existing
/etc/printcap file;  the apsfilter.conf file should either be
merged into the existing /usr/local/etc/apsfilter.conf file
or copied to the printer spool directory.

HORRIBLE THINGS ABOUT PAGE SIZES, ghostscript, and dvips

The various authors of ghostscript, dvips, and other tools have run into
nasty problems when trying to decide on paper sizes.  If you read the
GhostScript documentation and man pages,  it says that the page sizes
supported are defined in the gs_statd.ps file.  This file then states:

% Define various paper formats.  The Adobe documentation defines only these:
% 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.

If you read the file, then you discover that the following are defined:

       PAPERSIZE    X"         Y"         X cm      Y cm
       -----------------------------------------------------
       11x17        11"        17"        27.94     43.18
       a0           33.0556"   46.7778"   83.9611   118.816
       a10          1.02778"   1.45833"   2.61056   3.70417
       a1           23.3889"   33.0556"   59.4078   83.9611
       a2           16.5278"   23.3889"   41.9806   59.4078
       a3           11.6944"   16.5278"   29.7039   41.9806
       a4           8.26389"   11.6944"   20.9903   29.7039
       a5           5.84722"   8.26389"   14.8519   20.9903
       a6           4.125"     5.84722"   10.4775   14.8519
       a7           2.91667"   4.125"     7.40833   10.4775
       a8           2.05556"   2.91667"   5.22111   7.40833
       a9           1.45833"   2.05556"   3.70417   5.22111
       archA        9"         12"        22.86     30.48
       archB        12"        18"        30.48     45.72
       archC        18"        24"        45.72     60.96
       archD        24"        36"        60.96     91.44
       archE        36"        48"        91.44     121.92
       b0           39.3889"   55.6667"   100.048   141.393
       b1           27.8333"   39.3889"   70.6967   100.048
       b2           19.6944"   27.8333"   50.0239   70.6967
       b3           13.9167"   19.6944"   35.3483   50.0239
       b4           9.84722"   13.9167"   25.0119   35.3483
       b5           6.95833"   9.84722"   17.6742   25.0119
       flsa         8.5"       13"        21.59     33.02
       flse         8.5"       13"        21.59     33.02
       halfletter   5.5"       8.5"       13.97     21.59
       ledger       17"        11"        43.18     27.94
       legal        8.5"       14"        21.59     35.56
       letter       8.5"       11"        21.59     27.94
       note         7.5"       10"        19.05     25.4

You need (can) specify the papersize to gs by using:
  gs -sPAPERSIZE=letter

  Note:  the papersize must be one of the entries in column 1.

On the other hand,  a2ps --list-features yields:


Known media
  10x14     A3        A4        A4dj      A5        B4        B5
  Executive Folio     Ledger    Legal     Letter    Letterdj  Quarto
  Statement Tabloid

Note that 10x14 should be 11x14, and so forth, and that there are
some very odd sizes as well.  Also note that the names are Capitalized.

So, be careful when you are trying to set up new values for paper size -
you may run into problems.






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801100258.SAA05846>