PSUtils, written by Angus Duggan, is a collection of useful utilities for manipulating PostScript documents. Programs included are psnup, for placing out several logical pages on a single sheet of paper, psselect, for selecting pages from a document, pstops, for general imposition, psbook, for signature generation for booklet printing, and psresize, for adjusting page sizes.
The psbook program rearranges pages from a PostScript document into ``signatures'' for printing books or booklets, creating a new PostScript file.
Usage is:
psbook [ -q ] [ -ssignature] [infile[outfile] ]
Where -q surpresses printing of page numbers below the pages being rearranged (by default page numbers are printed), and -ssignature selects the size of signature which will be used. The signature size is the number of sides which will be folded and bound together; the number given should be a multiple of four. The default is to use one signature for the whole file. Extra blank sides will be added if the file does not contain a multiple of four pages.
The psnup program puts multiple logical pages onto each physical sheet of paper. The potential use of this utility is varied but one particular use is in conjunction with psbook. For example, using groff to create a PostScript document and lpr as the UNIX print spooler a typical command line might look like this:
% groff -Tps -ms file | psbook | psnup -2 | lpr
Where file is a four-page document this command will result in a two-page document printing two pages of file per page and rearranges the page order to match the input Pages 4 and 1 on the first output page and Pages 2 then 3 of the input document on the second output page.
Usage is:
psnup [ -wwidth] [ -hheight] [ -ppaper] [ -Wwidth] [ -Hheight][ -Ppaper] [ -l ] [ -r ] [ -f ] [ -c ] [ -mmargin][ -bborder] [ -dlwidth] [ -sscale ] [ -+nup] [ -q ][infile[outfile] ]
The -w option gives the paper width, and the -h option gives the paper height, normally specified in `cm' or `in' to convert PostScript's points (1/72 of an inch) to centimeters or inches. The -p option can be used as an alternative, to set the paper size to A3, A4, A5, B5, letter, legal, tabloid, statement, executive, folio, quarto or 10x14. The default paper size is A4.
The -W, -H, and -P options set the input paper size, if it is different from the output size. This makes it easy to impose pages of one size on a different size of paper.
The -l option should be used for pages which are in landscape orientation (rotated 90 degrees anticlockwise). The -r option should be used for pages which are in seascape orientation (rotated 90 degrees clockwise), and the -f option should be used for pages which have the width and height interchanged, but are not rotated.
Psnup normally uses ``row-major'' layout, where adjacent pages are placed in rows across the paper. The -c option changes the order to ``column-major'', where successive pages are placed in columns down the paper.
A margin to leave around the whole page can be specified with the -m option. This is useful for sheets of ``thumbnail'' pages, because the normal page margins are reduced by putting multiple pages on a single sheet.
The -b option is used to specify an additional margin around each page on a sheet.
The -d option draws a line around the border of each page, of the specified width. If the lwidth parameter is omitted, a default linewidth of 1 point is assumed. The linewidth is relative to the original page dimensions, i.e. it is scaled down with the rest of the page.
The scale chosen by psnup can be overridden with the -s option. This is useful to merge pages which are already reduced.
The -nup option selects the number of logical pages to put on each sheet of paper. This can be any whole number; psnup tries to optimise the layout so that the minimum amount of space is wasted. If psnup cannot find a layout within its tolerance limit, it will abort with an error message. The alternative form -n nup can also be used, for compatibility with other n-up programs. psnup normally prints the page numbers of the pages re-arranged; the -q option suppresses this feature.
The psselect program selects pages from a PostScript document, creating a new PostScript file. Usage is:
psselect [ -q ] [ -e ] [ -o ] [ -r ] [ -ppages] [pages][infile[outfile] ]
Where the -e option selects all of the even pages; it may be used in conjunction with the other page selection options to select the even pages from a range of pages, alternatively the -o option selects all of the odd pages; it also may be used in conjunction with the other page selection options.
The -ppages option specifies the pages which are to be selected. Pages is a comma-separated list of page ranges, each of which may be a page number, or a page range of the form first-last. If first is omitted, the first page is assumed, and if last is omitted, the last page is assumed. The prefix character ``_'' indicates that the page number is relative to the end of the document, counting backwards. If just this character with no page number is used, a blank page will be inserted in the output.
The -r option causes psselect to output the selected pages in reverse order.
psselect normally prints the page numbers of the pages rearranged; the -q option suppresses this. If any of the -r, -e, or -o options are specified, the page range must be given with the -p option.
The pstops program preforms general page rearrangement and selection, creating a new PostScript file. pstops can be used to perform a large number of arbitrary re-arrangements of documents, including arranging for printing 2-up, 4-up, booklets, reversing, selecting front or back sides of documents, scaling, etc.
Usage is:
pstops [ -q ] [ -b ] [ -wwidth] [ -hheight] [ -ppaper] [ -dlwidth]pagespecs[infile[outfile] ]
where pagespecs follow the syntax:
pagespecs = [modulo:]specs
specs = spec[+specs][,specs]
spec = [-]pageno[L][R][U][@scale][(xoff,yoff)]
modulo is the number of pages in each block. The value of modulo should be greater than 0; the default value is 1. specs are the page specifications for the pages in each block. The value of the pageno in each spec should be between 0 (for the first page in the block) and modulo-1 (for the last page in each block) inclusive. The optional dimensions xoff and yoff shift the page by the specified amount. xoff and yoff are in PostScript's points, but may be followed by the units `cm' or `in' to convert to centimetres or inches, or the flags `w' or `h' to specify as a multiple of the width or height. The optional flags L, R, and U rotate the page left, right, or upside-down. The optional scale parameter scales the page by the fraction specified. If the optional minus sign is specified, the page is relative to the end of the document, instead of the start. If page specs are separated by `+' the pages will be merged into one page; if they are separated by `,' they will be on separate pages. If there is only one page specification, with pageno zero, it may be omitted.
The shift, rotation, and scaling are performed in that order regardless of which order they appear on the command line.
The -w option gives the width which is used by the `w' dimension specifier, and the -h option gives the height which is used by the `h' dimension specifier. These dimensions are also used (after scaling) to set the clipping path for each page. The -p option can be used as an alternative, to set the paper size to A3, A4, A5, B5, letter, legal, tabloid, statement, executive, folio, quarto or 10x14. The default paper size is A4.
The -b option prevents any bind operators in the PostScript prolog from binding. This may be needed in cases where complex multi-page re-arrangements are being done.
The -d option draws a line around the border of each page, of the specified width. If the lwidth parameter is omitted, a default linewidth of 1 point is assumed. The linewidth is relative to the original page dimensions, i.e. it is scaled up or down with the rest of the page.
pstops normally prints the page numbers of the pages re-arranged; the -q option suppresses this feature.
The psresize program rescales and centres a document on a different size of paper. Usage is:
psresize [ -wwidth] [ -hheight] [ -ppaper] [ -Wwidth] [ -Hheight][ -Ppaper] [ -q ] [infile[outfile] ]
The -w option gives the output paper width, and the -h option gives the output paper height, normally specified in `cm' or `in' to convert PostScript's points (1/72 of an inch) to centimeters or inches. The -p option can be used as an alternative, to set the output paper size to A3, A4, A5, B5, letter, legal, tabloid, statement, executive, folio, quarto or 10x14. The default output paper size is A4. The -W option gives the input paper width, and the -H option gives the input paper height. The -P option can be used as an alternative, to set the input paper size. psresize normally prints the page numbers of the pages output; the -q option suppresses this feature.
The Graphics Cookbook