A2ps

From Christoph's Personal Wiki
Jump to: navigation, search

a2ps is an Any-to-PostScript filter.

Example usage

a2ps -Ppdf foo.txt

will create foo.pdf.

Available Escapes

Supported escapes are:

;`\\'
    character `\' 
`\%'
    character `%' 
`\$'
    character `$' 
`\#'
    character `#' 
`#?cond|if_true|if_false|'
    this may be used for conditional assignment. The separator (presented here as `|') may be any character. if_true and if_false may be defined exactly the same way as regular headers, included escapes and the `#?' construct. The available tests are:

    `#?1'
    `#?2'
    `#?3'
        true if tag 1, 2 or 3 is not empty. See item `$t1' for explanation. 
    `#?d'
        true if Duplex printing is requested (`-s2'). 
    `#?j'
        true if bordering is asked (`-j'). 
    `#?l'
        true if printing in landscape mode. 
    `#?o'
        true if only one virtual page per page (i.e., `#v' is 1). 
    `#?p'
        a page range has been specified (i.e., `#p' is not empty). 
    `#?q'
        true if a2ps is in quiet mode. 
    `#?r'
        true if major is rows (`--major=rows'). 
    `#?v'
        true if printing on the back side of the sheet (verso). 
    `#?V'
        true if verbosity level includes the `tools' flag (See section 3.1.2 Global Options option `--verbosity'. 

`#!key|in|between|'
    Used for enumerations. The separator (presented here as `|') may be any character. in and between are escapes. The enumerations may be:

    `#!$'
        enumeration of the command line options. In this case in in never used, but is replaced by the arguments. 
    `#!f'
        enumeration of the input files in the other they were given. 
    `#!F'
        enumeration of the input files in the alphabetical order of their names. 
    `#!s'
        enumeration of the files appearing in the current sheet. 

    For instance, the escapes `The files printed were: #!f|$n|, |.' evaluated with input `a2ps NEWS main.c -o foo.ps', gives `The files printed were: NEWS, main.c.'. As an exception, `#!' escapes use the width as the maximum number of objects to enumerate if it is positive, e.g., `#10!f|$n|, |' lists only the ten first file names. If width is negative, then it does not enumerate the -width last objects (e.g., `#-1!f|$n|, |' lists all the files but the last). 
`${var}'
    value of the environment variable var if defined, nothing otherwise. 
`${var:-word}'
    if the environment variable var is defined, then its value, otherwise word. 
`${var:+word}'
    if the environment variable var is defined, then word, otherwise nothing. 
`$[num]'
    value of the numth argument given on the command line. Note that $[0] is the name under which a2ps has been called. 
`#{key}'
    expansion of the variable key if defined, nothing otherwise (see section 4.1.8 Your Escapes) 
`#{key:-word}'
    if the variable var is defined, then its expansion, otherwise word. 
`#{key:+word}'
    if the variable var is defined, then word, otherwise nothing. 
`#.'
    the extension corresponding to the current output language (e.g. `ps'). 
`%*'
    current time in 24-hour format with seconds `hh:mm:ss' 
`$*'
    file modification time in 24-hour format with seconds `hh:mm:ss' 
`$#'
    the sequence number of the current input file 
`%#'
    the total number of files 
`%a'
    the localized equivalent for `Printed by User Name' 
`%A'
    the localized equivalent for `Printed by User Name from Host Name' 
`%a{username}'
    the localized equivalent for `Printed by username' 
`%A{username@hostname}'
    the localized equivalent for `Printed by username from hostname'. These two are provided in the case a2ps would be used by the print service: since neither of the user name nor the host name can be known at the time the files reach a2ps, these options should be used. 
`%c'
    trailing component of the current working directory 
`%C'
    current time in `hh:mm:ss' format 
`$C'
    file modification time in `hh:mm:ss' format 
`%d'
    current working directory 
`$d'
    directory part of the current file (`.' if the directory part is empty). 
`%D'
    current date in `yy-mm-dd' format 
`$D'
    file modification date in `yy-mm-dd' format 
`%D{string}'
    format current date according to string with the strftime(3) function. 
`$D{string}'
    format file's last modification date according to string with the strftime(3) function. 
`%e'
    current date in localized short format (e.g., `Jul 4, 76' in English, or `14 Juil 89' in French). 
`$e'
    file modification date in localized short format. 
`%E'
    current date in localized long format (e.g., `July 4, 76' in English, or `Samedi 14 Juillet 89' in French). 
`$E'
    file modification date in localized long format. 
`$f'
    full file name (with directory and suffix). 
`\f'
    character `\f' (form feed). 
`#f0'
`#f9'
    ten temporary file names. You can do anything you want with them, a2ps removes them at the end of the job. It is useful for the delegations (see section 4.1.9 Your Delegations) and for the printer commands (see section 4.1.4 Your Printers). 
`%F'
    current date in `dd.mm.yyyy' format. 
`$F'
    file modification date in `dd.mm.yyyy' format. 
`#h'
    medium height in PostScript points 
`$l^'
    top most line number of the current page 
`$l.'
    current line number. To print the page number and the line interval in the right title, use `--right-title="$q:$l^-$l."'. 
`$l#'
    number of lines in the current file. 
`%m'
    the host name up to the first `.' character 
`%M'
    the full host name 
`\n'
    the character `\n' (new line). 
`%n'
    the user login name 
`$n'
    input file name without the directory part. 
`%N'
    the user's pw_gecos field up to the first `,' character (typically his/her full name). 
`$N'
    input file name without the directory, and without its suffix (e.g., on `foo.c', it will produce `foo'). 
`#o'
    name of the output, before substitution (i.e., argument of `-P', or of `-o'). 
`#O'
    name of the output, after substitution. If output goes to a file, then the name of the file. If the output is a symbolic printer (see section 4.1.4 Your Printers), the result of the evaluation. For instance, if the symbolic printer `file' is defined as `> $n.%.', then `#O' returns `foo.c.ps' when printing `foo.c' to PostScript. `#o' would have returned `file'. 
`#p'
    the range of the page to print from this page. For instance if the user asked `--pages=1-10,15', and the current page is 8, then `#p' evaluates to `1-3,8'. 
`$p^'
    number of the first page of this file appearing on the current sheet. Note that `$p.', evaluated at the end of sheet, is also the number of the last page of this file appearing on this sheet. 
`$p-'
    interval of the page number of the current file appearing on the current sheet. It is the same as `$p^-$p.', if `$p^' and `$p.' are different, otherwise it is equal to `$p.'. 
`%p.'
    current page number 
`$p.'
    page number for this file 
`%p#'
    total number of pages printed 
`$p#'
    number of pages of the current file 
`$p<'
    number of the first page of the current file 
`$p>'
    number of the last page of the current file 
`%q'
    localized equivalent for `Page %p.' 
`$q'
    localized equivalent for `Page $p.' 
`%Q'
    localized equivalent for `Page %p./%p#' 
`$Q'
    localized equivalent for `Page $p./$p#' 
`$s<'
    number of the first sheet of the current file 
`%s.'
    current sheet number 
`$s.'
    sheet number for the current file 
`$s>'
    number of the last sheet of the current file 
`%s#'
    total number of sheets 
`$s#'
    number of sheets of the current file 
`%t'
    current time in 12-hour am/pm format 
`$t'
    file modification time in 12-hour am/pm format 
`$t1'
`$t2'
`$t3'
    Content of tag 1, 2 and 3. Tags are pieces of text a2ps fetches in the files, according to the style. For instance, in mail-folder style, tag 1 is the title of the mail, and tag 2 its author. 
`%T'
    current time in 24-hour format `hh:mm' 
`$T'
    file modification time in 24-hour format `hh:mm' 
`#v'
    number of virtual sheets 
`%V'
    the version string of a2ps. 
`#w'
    medium width in PostScript points 
`%W'
    current date in `mm/dd/yy' format 
`$W'
    file modification date in `mm/dd/yy' format

External links