Psnup2.pl: a better “psnup -2

Psnup2.pl puts two PostScript pages onto one page. It is similar to “psnup -2”, but

psnup -2 Better: psnup2.pl
psnup -2 Better: psnup2.pl

Download

psnup2-0.0.5.tar.gz

Public domain, © Oleg Parashchenko, Lionel Guy <guy.lionel gmail com>.

Usage

psnup2.pl
-d -m <margin> -w <page_width> -h <page_height> -l <n_long_edge> -s <n_short_edge> -r <reverse> -D SOURCE [DEST]

Example 1

Issue the following command to convert input.ps and save the result as output.ps.

$ psnup2.pl input.ps output.ps

Example 2

Psnup2.pl is a Perl-wrapper around pstops. Use the option -d to get the pstops command line.

$ psnup2.pl -d input.ps output.ps
pstops -w595 -h842 '2:0L@0.698(591.3,9.7)+1L@0.698(591.3,416.4)' input.ps output.ps
And add after the first '%%EndComments':
%%BeginFeature: *PageSize (595 842)
<< /PageSize [595 842] >> setpagedevice
%%EndFeature

Example 3

To print 8 pages per page (useful for slides):

$ psnup2.pl -l 4 -s 2 -r slides.ps toprint.ps

Example 4

One page per page, to enlarge the text area and lessen the margins:

$ psnup2.pl -l 1 -s 1 small.ps big.ps

The bug

There are a lot of problems with pstops. To workaround them, psnup2.pl changes the PostScript result. Details are in the source code. In any case, if gv displays something badly, it doesn't mean the page will be printed badly. Use ps2pdf to preview the expected result.

Here is an example of a problem. Using the old version 0.0.1, on some systems you get an extra margin at the top, and the content is cut at the bottom. Here is the fix and adapted explanation by George V. Kouryachy.

So. The error is deep in psutils. The code, which changes the page format, is inserted before the specification of the paper size. Therefore, the reformatting code takes the default paper size. It's “letter”. Three solutions are possible.

…Ideas on refactoring of psutils are skipped…

Just change the default paper size. In the file /usr/share/ghostscript/8.15/lib/gs_init.ps or similar, uncomment the following line.

% /DEFAULTPAPERSIZE (a4) def

Starting with the version 0.0.2, psnup2.pl sets the paper size in the output PostScript document. Now you don't have this problem with psnup2.pl and don't need to edit gs_init.ps, but the explanation is retained to help with other programs.

Links


Oleg Parashchenko