Psnup2.pl puts two PostScript pages onto one page. It is similar to “psnup -2”, but
![]() |
![]() |
| psnup -2 | Better: psnup2.pl |
Public domain, © Oleg Parashchenko.
Issue the following command to convert input.ps and save the result as output.ps.
$ psnup2.pl input.ps output.ps
Psnup2.pl is a Perl-wrapper around pstops. Use the option -n to get the pstops command line.
$ psnup2.pl -n 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
To print 8 pages per page (useful for slides), use the option -8.
The script is an useful quick hack, not a full-featured program. If you want to customize it, edit the source code.
To change the paper dimensions, edit the following variables.
my ($page_width, $page_height) = (21.0, 29.7); # in cantimeters, A4 my $margin = 1; # in cantimeters
The “letter” page size is 21.6cm x 27.9cm.
To change the number of pages per page, edit the procedure calculate_views. The procedure returns an array of the target areas. Each area is a reference to an array (x1,y1,x2,y2), where (x1,y1) and (x2,y2) are the coordinates of the left bottom and right top corners, respectively. The measure unit is the PostScript point.
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.