psnup -2

psnup allows to have multiple pages per sheet in a postscript file. I have printed a book called The Art Of Unix Programming from Eric Steven Raymond. It has 540 pages, so I decided to print two pages per one sheet of paper and use double side.

Have a ps file.

psnup works with postscript (ps) files, but I had a pdf file; using acroread converted the pdf file to a ps file by just printing it to a file. Another approach is to use pdf2ps from GNU Ghostscript.

Put numbers.

As the ps file didn't have any number as footer or header, I had to put them on it. As I got tired of searching for a tool that accomplish that task, I decided to put them with an editor. I don't know the postscript language (And I don't want to learn) but it took me some minutes to notice that the following code will put the numbers:

        280 17 m
        (17)
        [10.1078 7 10.892 6.21579 ] pdfxs

where (17) is the page number. There is a ps command that tells which number page you are in:

        %%Page: 17 17

Then I created a vi macro (Vim the editor, http://www.vim.org) with qq (start 'q' macro):

        /%%Page:^Mwwyaw/pdfxs^Mo280 17 m^M/N6514 14 Tf^M()^M[10.1078 7 10.892
        6.21579 ] pdfxs^[kPx

which reads as:

/%%Page:
search next pattern

wwyaw
move two words forward, then yank a word yaw

/pdfxs
search next pattern

o
new line, then write the text:
        280 17 m
        ()
        [10.1078 7 10.892 6.21579 ] pdfxs

^[
escape

k
move one line backward

P
paste the number

x
delete space

NOTE: ^M is an enter.

After that I tested that the macro worked for the next page and it did (@q calls the 'q' macro), I let vim work:

        600@q

Use psnup.

Just write:

        psnup -2 book.ps double.ps

And print it.

Author.

               Luis Alfonso Vega GarcĂ­a
 Ingeniero en Sistemas Computacionales
  webpage: http://mx.geocities.com/elvegamx/
   use jdirdiff: http://www.google.com.mx/search?q=jdirdiff
    LPI000053380 -- Linux User: 326423 at http://counter.li.org/
     gpg-key:
 http://vegacom.blogspot.com/2004/09/vegacomgmailcom-gpg-public-key.html
Return
Hosted by www.Geocities.ws

1