TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

PostScript-Tricks
 Main page Index UK FAQ Documentation Software CTAN Search CTAN: Statistics Google c.t.t. Google d.c.t.t.

More Links (under subject "Postscript") |  Booklet |  Border around each Page  |  Merge Postscript files |  Resizing Postscript-Output |

Print a border around each Page
an easy way is to print the ps-output with psnup
 psnup -b10 -d1 yourFile.ps | lpr

b10: 10 pixel border
d1: draw line with a width of 1 pixel

Print Output as Booklet
Save the following shellscript as book4, make it executable and run it like
 book4 myOutput.ps | lpr
than you'll get it printed as booklet. If you don't have a duplex-unit for your printer save the output into a file (book4 myOutput.ps > new.ps) and print odd/even pages separately.
 #!/bin/sh # script for book generation. # Examples of use: # # man -t | book4 | lpr -P # This will print the man pages in book format and # both sides. If you need file out, say: # man -t | book4 > out.ps # cat name.ps | book4 > name2.ps # ps-file to book-format # book4 name.ps | lpr # same #PATH=/usr/local/bin:/usr/bin:/bin #export PATH PSBOOK=/usr/bin/psbook PSNUP=/usr/bin/psnup PSTOPS=/usr/bin/pstops if test $# -gt 0; then for N in$*; do $PSBOOK -q$N | $PSNUP -q -2 |$PSTOPS -q "2:0,1U(1w,1h)" done else $PSBOOK -q |$PSNUP -q -2 | \$PSTOPS -q "2:0,1U(1w,1h)" fi 
The same is possible with the following PostScript command
 psbook document.ps | pstops -pa4 4:0@.7L(21cm,00)+1L@.7(21cm,14.8cm),2L@.7(21cm,00)+3L@.7(21cm,14.8cm) > output.ps 
(all on one line).

Explanation of the commands:
psbook rearranges the order of the pages of the original document.ps file into a new one, appropriate for double-face booklet printing; the output is then piped (via the | shell command) to pstops that acts on the pages to create new physical pages containing groups of logical pages from the old document, according to the following rules:

-pa4 (final paper format is A4)
4: (group pages into 4-page booklets)
0 (page 0 from each group should be:
@.7 (scaled by .7, which is the reciprocal of \sqrt{2}, that is the ratio between the original A4 paper format and the final reduced page size, which is an A5, aka half an A4: A4 has dimension in a \sqrt{2} ratio, and thus the .7)
L (rotated by a quarter of a circle to the left)
(21cm,0) (translated to this position on the new physical page) )
+ (add the next page spec to this same side of the new physical page)
1 (page 1 from each group should be:
@.7 (scaled by .7, which is the reciprocal of \sqrt{2}, that is the ratio between the original A4 paper format and the final reduced page size, which is an A5, aka half an A4: A4 has dimension in a \sqrt{2} ratio, and thus the .7)
L (rotated by a quarter of a circle to the left)
(21cm,14.8) (translated to this position on the new physical page) )
, (add the following page specs to the other side of the new physical page) and so on and so forth. If the original document is already in half/A4 format (a5paper) you can leave out the @.7 specs from the page rearrangements.

Merge Postscript Files
You need Ghostscript, which is available here. Merging is possible with the following command:
 ghostscript -dNOPAUSE -sDEVICE=pswrite -dBATCH -sOutputFile=out.ps part1.ps part2.ps part3.ps ...

Resizing Postscript Output
for example to resize a paper in DINA3 format to DINA5 format run:

 psresize -Pa3 -pa5 test.ps | lpr
or from a specific size to a4 paper
 psresize -W21cm -H40cm -pa4 test.ps | lpr
or
 psresize -Pa3 -w6cm -w4cm test.ps | lpr