[gs-devel] gs and output page selection: a feature request
Nelson H. F. Beebe
beebe at math.utah.edu
Sat Apr 13 15:01:00 PDT 2002
After reviewing the ghostscript/7.20/doc/Use.htm file, it does not
appear to be possible to request gs to output only selected pages.
Adobe Distiller 3.0 (the only version one available on UNIX systems)
similarly lacks this feature.
This capability has long been provided by most TeX DVI drivers, for a
wide variety of output devices, and it is often quite useful, and
sometimes, essential.
This letter is a request for consideration of adding a page selection
feature to ghostscript command-line options.
The remainder of this communication is documentation of prior art to
justify the request, and provide ideas for software design.
gs-devel list readers are invited to report documentation snippets of
similar features in other PostScript- and/or PDF-producing or processing
software.
------------------------------------------------------------------------
GNU groff provides page selection with the option
-olist output only pages in list
or in more detail from the groff info pages:
`-oLIST'
Output only pages in LIST, which is a comma-separated list
of page ranges; `N' means print page N, `M-N' means print
every page between M and N, `-N' means print every page up
to N, `N-' means print every page beginning with N.
`gtroff' will exit after printing the last page in the
list. All the ranges are inclusive on both ends.
Within `gtroff', this information can be extracted with the
`.P' register. *Note Built-in Registers::.
------------------------------------------------------------------------
AT&T UNIX troff provides
-olist Output only pages in list, which is a comma-sep-
arated list of page ranges; n means print page
n, m-n means print every page between m and n,
-n means print every page up to n, n- means
print every page from n. Troff will exit after
printing the last page in the list.
------------------------------------------------------------------------
Adobe acroread (version 4.05 on UNIX):
-reverse - reverse the page order of the output
-odd - emit only odd-numbered pages
-even - emit only even-numbered pages
-start <int> - identify the first page in the document to be
converted (default is the first page of the
document)
------------------------------------------------------------------------
Adobe psdit in the TranScript package provides
-olist prints pages whose numbers are given in the comma-
separated list. The list contains single numbers N
and ranges N1-N2. A missing N1 means the lowest-
numbered page, a missing N2 means the highest.
------------------------------------------------------------------------
Adobe pslpr in the TranScript package provides
-ipagerange
pagerange may be a single page number or a range of
the form "N-M" which means print pages N through M.
Multiple instances of pagerange may be specified by
repetitive use of this option.
-R reverses the page order.
------------------------------------------------------------------------
a2ps (ftp://ftp.enst.fr/pub/unix/a2ps/a2ps-4.13b.tar.gz) provides
-a, --pages[=RANGE]
select the pages to print
or, in more detail from the a2ps info pages:
- Option: -a[PAGE RANGE]
- Option: --pages[=PAGE RANGE]
With no argument, print all the page, otherwise select the
pages to print. PAGE RANGE is a list of interval, such as
`-a1': print only the first page, `-a-3,4,6,10-': print the
first 3 pages, page 4 and 6, and all the page after 10
(included). Giving `toc' prints the table of content
whatever its page number is.
The pages referred to are the _input_ pages, not the output
pages, that is, in `-2', printing with `-a1' will print the
first virtual page, i.e., you will get half the page filled.
Note that page selection does work with the delegations
(*note Your Delegations::).
------------------------------------------------------------------------
My lptops (ftp://ftp.math.utah.edu/pub/misc/lptops-3.1.5.tar.gz)
provides
-pages=#,#,#,...
Select pages to be output. Each entry in the
comma-separated list is a page number, or a page range,
or a page range and page step. Numbers within an entry
can be separated by any character other than a digit or
comma. For example, -pages=1,7,10-12,20:30:2 would
select pages 1, 7, 10, 11, 12, 20, 22, 24, 26, 28, and
30. If multiple -pages options are specified, their
effect is cumulative. The previous example could be
written equivalently as -pages=1 -pages=7 -pages='10 up
to 12' -pages='20 to 30 by 2'. The order of multiple
-pages options, and page ranges, is not significant; thus
-pages=1:20:2 -pages=2:20:2 would print all pages from 1
to 20 consecutively, not odd-numbered pages followed by
even-numbered pages. To accomplish the latter, you must
run lptops twice.
------------------------------------------------------------------------
In my own TeX DVI driver family, I offer an even more powerful page
selection facility, designed to also conveniently handle the common
case of separately-numbered front matter in reports, books, theses,
..., and the fact that TeX supplies 10 (yes, ten) page counter
registers for complex page numbering requirements:
-backwards{[#]}
Flip or set the backwards printing order flag. For
example, laser printers using the Canon LBP-CX print
engine should normally receive pages in reverse order
because they stack printed side up. However, some
printers with this engine have page handling mechanisms
that stack pages face down, and in such a case -backwards
will ensure that they come out in order 1, 2, 3,
... instead of n, n-1, n-2, ....
-o<selection>
Specify a page number, or range of page numbers, or list
of page numbers, to be selected for output. This option
may be given any number of times; each new selection is
appended to the current selection list. However, for
interactive display drivers, only the initial page number
of the first -o switch is used.
If this option is not specified, then all pages will be
output.
The <selection> value may be either a colon-separated
list of 1 to 4 decimal numbers, or a comma-separated list
of 1 or more numbers, or a dot-separated list of 1 to 10
decimal numbers. Embedded whitespace is not permitted in
the list.
The commonest form is the colon-separated list, which
specifies page numbers according to their sequential
order in the DVI file, starting from 1. The first number
is the starting page number, the second is the ending
number, the third is the page number step size (default
1). The fourth number is an offset to be added to the
first and second numbers; this is a convenience when the
document contains leading material before page 1. A
value from a previously-specified -offset switch will
also be added to the first and second numbers.
When a comma-separated list of numbers is provided, only
those pages are selected for printing. A value from a
previously-specified -offset switch will also be added to
each of the numbers.
Negative page numbers count backward; -1 is the last page
in the document, -2 the second last page, and so on.
If the second number is prefixed by an explicit plus
sign, it is taken as a page count, instead of an ending
page number.
For example, -o1:3 -o12 -o17:23 -o-3:-1 would select
pages 1, 2, 3, 12, 17, 18, 19, 20, 21, 22, and 23, plus
the last three pages. -o88:98:1:7 would select pages 95
through 105, since an offset of 7 is to be added to the
starting and ending page numbers. -o88:+10:1:7 would
select the same set of pages. -o2,3,12,27 would select
pages 2, 3, 12, and 27.
Specification of a page number step size is useful for
producing duplex (two-sided) printing. For example, with
laser printers using the Canon LBP-CX engine, the first
run could specify -o1:9999:2, which would stack output
face up, beginning with the last page, and ending with
page 1 on top. The printed pages can then be reinserted
in the input tray face up, page 1 on the top, exactly as
they were found in the output tray, with the top of the
page in the tray closest to the end which is inserted
first into the printer. A second run with -backwards
-o2:9999:2 would then print pages 2, 4, ..., on the backs
of pages 1, 3, ...; note the -backwards option to get
backwards order on the second run.
The alternate form of <selection> is a dot-separated
list to provide for matching against the TeX \count0
... \count9 values stored with each page in the DVI file.
Each item in the list is either a single number
specifying an exact match with the corresponding \count
value, a colon-separated pair of numbers defining a range
in which the corresponding \count value is found, or
corresponding \count. If fewer than ten items are
provided, the omitted ones always match. Any \count
value that is zero always matches the corresponding item,
because unset counters are set to zero by TeX.
For example, -o1:3.*.4 matches pages with \count0 in the
range 1...3, and \count2 equal to 4; all other counter
values are ignored.
As pages are selected for printing, [#{#} will be printed
on stderr, where the first # is the page number in the
file, and the second # is a string of values of the TeX
counters \count0 through \count9, separated by dots, with
trailing zero counters dropped. \count0 usually records
the printed page number. When the page is completely
output, a closing ] will be printed on stderr. Any error
messages from processing of that page will therefore
occur between the square brackets.
Pages are processed in the order found in the DVI file;
there is intentionally no attempt made to sort them
according the \count0 values, since different macro
packages may use this counter for different purposes, and
in the case of floating tables and figures, the pages may
not be in order anyway.
-offset#
Documents with front matter may have several pages
preceding the physical page that is numbered 1. To ease
specification of page numbers, this option can be used to
provide a constant offset to be added to all succeeding
page numbers specified in -o switches. That offset
remains in effect until overridden by a later -offset#
switch.
------------------------------------------------------------------------
-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- Center for Scientific Computing FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah Internet e-mail: beebe at math.utah.edu -
- Department of Mathematics, 110 LCB beebe at acm.org beebe at computer.org -
- 155 S 1400 E RM 233 beebe at ieee.org -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe -
-------------------------------------------------------------------------------
More information about the gs-devel
mailing list