Le GNU a2ps - Delegations

Le GNU a2ps

Delegations

General Info

What is GNU a2ps
Features of 4.13
Features of 4.12
Features of 4.10.4
Contributions
Projects Related with a2ps
Ports and Packages
Ports to M$ world
Giving Feedback

Documentation

Manual of 4.12
Manual of 4.10
Manual of 4.8
Glossary
Known Bugs
FAQ
a2ps List Archive

Extensions

Sheets Files
Delegations

Internationalization

a2ps & I18n
Existing Translations
Working on Translation
Guide Line

Development

Download
NEWS

Starting at version 4.9.7, a2ps may delegate the processing of some files to other filters. This has been made to:

  • avoid bad surprises.

    Indeed, there are very few people interested in print PostScript code: most people just want to send the PostScript file to the printer. This is now the default behavior of a2ps.

  • offer a uniform interface to different programs.

    Most people do not want to learn as many interfaces to print a file as there are types of files. Through its delegating commands, a2ps is able to pass the equivalent of its option to the delegations. For instance, if you ask a2ps -2 file.ps man_page.1 page.html program.c -d, then a2ps will call psnup, groff, Netscape and itself with all the needed options to get a single PostScript file, 2 up, and send it to the printer.

Here, we list some of these applications, where to find them, how to configure them for a2ps. If you know others, if you know other useful delegations, please send them to us, so that this page gets updated.

DVI filters

DVI is the standard output format of TeX, LaTeX etc.

dvips

Use:

# Calls to dvips.  The sequence waits for the file name, and
# produces on stdout.
MacroMetaSequence: dvips dvips #?p|-pp#p|| #?V||-q| -T#wpt,#hpt -f

# Pass DVI files to dvips.
# A problem with dvips is that even on failure it dumps its prologue,
# hence it looks like a success (output is produced).
# To avoid that, we use an auxiliary files and conditional call to
# psnup instead of piping.
Delegation: dvips dvi:ps\
        #{dvips} $f -o #f0 && #{psnup} #f0

Compression filters

gzip

This delegation is particular: once the file is uncompressed, another a2ps is called onto the decompressed file. This is because the type of a compressed PostScript file is compressed, not compressed postscript. So a2ps is called on the uncompressed file, which type will now be correctly recognized.

# a2ps will be called upon decompressed files.
MacroMetaSequence: a2ps\
 a2ps #?p|-a#p|| #?V|-v2|-q| -#v -o-

# A compressed file should be decompressed and processed by a2ps
# A consequence is that the decompressed file may be delegated.
Delegation: Gzip-a2ps compressed:ps     \
  gzip -cd $f | #{a2ps} --stdin=$N

HTML filters

Lynx

Lynx is a free textual web browser. If you do have Lynx, prefer its use for a2ps than Netscape (which may cause problems in addition of requiring to be yet running). There is one big difference though: with Lynx you will get a pure textual output proceesed by a2ps, though with Netscape real nice PostScript is produced (including the pictures etc.). Use this entry:

# Delegate to lynx the interpretation of an html page.
Delegation: Lynx html:ps      \
       lynx -force_html -nolist -dump $f \
       | #{a2ps} --delegate=no --stdin=$f

Netscape

If Netscape is running, then a2ps can call it to produce the PostScript. Use this entry:

########## HTML files
# Pass HTML to Netscape, hoping that there is an Netscape running...
# Tricks:
# 1. Netscape can't output on stdout, hence use a tmp file (#f0)
# 2. openfile refuses relative paths, so prepend cwd (%d) when relative
# 3. remote 'openfile' -remote 'saveas' is bad, because it is handled
#    asynchronously, and the output can correspond to a previously
#    loaded page (not that of openfile).  So run Netscape twice.
# 4. It asks the user if s/he wants to replace an existing output file,
#    so rm before.
Delegation: Netscape html:ps    \
  rm -f #f0; \
  if echo "$f" | grep '^/' >/dev/null 2>&1; then \
    ${NETSCAPE:-netscape} -noraise -remote 'openfile($f)'; \
  else \
    ${NETSCAPE:-netscape} -noraise -remote 'openfile(%d/$f)'; \
  fi && \
  ${NETSCAPE:-netscape} -noraise -remote 'saveas(#f0,postscript)' && \
  #{del.psselect} #f0 | #{del.psnup}

LaTeX filters

LaTeX

Personally I use:

Delegation: LaTeX tex:ps	\
    TEXINPUTS=$d:$$TEXINPUTS \
    latex '\\nonstopmode\\input{$f}' #?V|1>&2|> /dev/null| && \
    #{dvips} $N.dvi | #{psnup}

PostScript filters

PostScript Utils by Angus Duggan

This is a collection of very nice tools for post-processing PostScript files. Consider this package to be required for a very good functioning of delegations.

To set this delegation, insert this in one of a2ps' configuration files:

# Passes the options to psnup.  A problem with psnup is that even if
# no service is ask, the PostScript is altered.  There are such problems
# with dvips.  A symptom is that the figure are spread on several
# pages.  To avoid that, with ``-1'', we use cat instead of psnup -1.
# The files (in and out) are to be given
MacroMetaSequence: psnup \
   #?o!cat!psnup -#v #?V||-q| #?j|-d|| #?r||-c| -w#w -h#h!

# Passes to psselect for PS page selection.
MacroMetaSequence: psselect \
   #?p!psselect #?V||-q| -p#p!cat!

# In general, people don't want to pretty-print PostScript files.
# Pass the PostScript files to psnup
Delegation: PsNup ps:ps #{psselect} $f | #{psnup}

Roff filters

Roff is used to write, among others, the man pages.

Groff

Groff may be found anywhere GNU programs are distributed. Use:

# Pass the roff files to groff.  Use grog to guess the right options.
Delegation: Groff roff:ps       \
        eval `grog -Tps $f` | #{psselect} | #{psnup}

Texinfo filters

Texinfo is the new standard for write ``man pages''. It uses TeX (and then dvips) to produce the printable version of the documentation.

Texi2dvi

Texi2dvi may be found anywhere GNU programs are distributed. Nevertheless, you should take advantage of this modified version which introduces useful options (especially when delegating). Use:

# We use a modified texi2dvi (which accepts -b, and -c)
# We put the directory of the file ($d) in the TeX path.
MacroMetaSequence: texi2dvi \
 MAKEINFO='makeinfo -I $d' texi2dvi4a2ps -b -c #?V|--verbose|| #?V|1>&2|>/dev/nu
ll|

# Call to tex2dvi for texinfo file
# Note: the patch for texidvi _must_ be applied
Delegation: texi2dvi texinfo:ps \
  #{texi2dvi} $f && mv $N.dvi #f0 && #{dvips} -f #f0 | #{psnup}