upprint: tools for better n-up printing



Typical 2-up page placement
2-up page placement with upprint
The upprint package contains tools for better formatting of print jobs. Unlike print systems such as CUPS, which delegate all formatting to the print server, the upprint tools are designed to work on the user side, and therefore under the user's control. The package provides the following tools:
  • pstops-clip: an extension of Angus J. C. Duggan's pstops program for reformatting postscript files. The extension allows configurable page clipping.
  • psdim: a small utility to be used in conjunction with pstops. It determines the true margins of a postscript documents and calculates the optimal page placement for n-up printing. It outputs a format string suitable for processing by pstops or pstops-clip. In order to accurately determine the size of the pages in a postscript document, psdim internally uses the ghostscript interpreter to render the document. For this reason, psdim is relatively slow, but much more accurate than other tools.
  • lprwrap: a wrapper around the standard "lpr" program. Lprwrap is a client-side program, which means, all processing is done under your control before passing the print job to lpr. Lprwrap can convert common file formats to postscript. It recognizes special options for duplex printing and n-up printing. It handles n-up printing intelligently, with optimal margins based on the actual document (see above illustration).


For changes prior to version 1.5, see the file NEWS. For a more detailed list of changes, see the ChangeLog.

November 24, 2019: Release 1.8. Added more options for setting margins. Added a 'custom' paper size to lprwrap. Added support for using enscript instead of mpage.

March 27, 2012: Release 1.7. Portability improvements. Lprwrap: pass unrecognized -o options to the underlying lpr, so that applications expecting a CUPS lpr will still work. Changed the way lprwrap calls the "real" lpr.

July 23, 2011: Release 1.6. Improved portability. Lprwrap: Compatibility with newer versions of CUPS has been improved. The -ocups option to lprwrap now replaces the old lprwrap-cups script. Allow multiple -ofudge options. New --lpr option can be used to specify the backend "lpr" executable. The TEMPDIR environment variable is now respected. Support for pdftops added. Added a size limit on text files, and a --force option to override it. Psdim: when compiled with metric defaults, use metric units in the output format string. New options --[lrtb]adjust for adjusting the bounding box of input document. Compensate for certain PostScript files generated by Acrobat Reader that resulted in shifted output.

February 15, 2007: Release 1.5. The new upprint package combines the features of the old lpr-wrapper and psdim packages. It contains lprwrap, psdim, as well as the new program pstops-clip. Page clipping was improved, so that documents with opaque backgrounds can now be printed in n-up mode. A 'fudge' feature was added to allow more flexible margin detection. The lpr-wrapper program was renamed lprwrap.


If you would like to ensure the accuracy of the downloaded files, you can double-check their SHA1 sums.

Source distribution: upprint-1.8.tar.gz


For psdim to work, ghostscript must be installed on your system.

For lprwrap to work, you need at least: bash, lpr, file, mktemp, sed, and awk. For enhanced functionality, you should also have: getopt, mpage, gzip, bzip2, iconv, dvips, and pdf2ps.

For your convenience, here are some links to the required packages. The software marked "*" is required.


You can build and install the upprint tools from sources using the standard configure/make commands. Please see the file INSTALL for generic installation instructions. Also see the file README for specific compile time configuration options. Redhat RPM packages are also available.

Lprwrap examples and customization

You can use the lprwrap program in the same way you normally use "lpr", for example:
  lprwrap -oduplex test.ps
This should print the page in duplex (double-sided) format, if your printer allows it. If you are using the CUPS printing system, use
  lprwrap -ocups -oduplex test.ps
instead. Also try 2-up printing with
  lprwrap -o2up test.ps

For ease of use, you can create an alias, for example by putting the following into the ".bashrc" file in your home directory:

  alias lpr='lprwrap -h'
You can now run the lprwrap utility by the name "lpr". The older method, which involved renaming "lprwrap" as "lpr", is no longer recommended.

Psdim examples

In the simplest case, psdim can be used to figure out an optimal format string for 2-up printing:

              % psdim --2up test.ps
              [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
The resulting format string can be fed directly to pstops:

              % pstops `psdim --2up test.ps` test.ps test.2up.ps
              [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
              [1] [2] [3] [4] [5]
              Wrote 5 pages, 155746 bytes


For usage instructions, see the file README.

You can also view the man pages lprwrap(1), psdim(1), and pstops-clip(1).

Related software

  • Ghostscript. The PostScript interpreter. Required by psdim.




For psdim and lprwrap:

Copyright © 2001-2019 Peter Selinger.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

See the file COPYING for details.

For pstops-clip:

Copyright © 1991-1995 Angus J. C. Duggan.
Copyright © 2006-2019 Peter Selinger.

This program may be copied and used for any purpose (including distribution as part of a for-profit product), provided:

  1. The original attribution of the programs is clearly displayed in the product and/or documentation, even if the programs are modified and/or renamed as part of the product.

  2. The original source code of the programs is provided free of charge (except for reasonable distribution costs). For a definition of reasonable distribution costs, see the Gnu General Public License or Larry Wall's Artistic License (provided with the Perl 4 kit). The GPL and Artistic License in NO WAY affect this license; they are merely used as examples of the spirit in which it is intended.

  3. These programs are provided "as-is". No warranty or guarantee of their fitness for any particular task is provided. Use of these programs is completely at your own risk.

See the file pstops-clip/LICENSE for details.

Back to Homepage: [home]
Peter Selinger / Department of Mathematics and Statistics / Dalhousie University
selinger@users.sourceforge.net / PGP key