Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have an PostScript output from a man page produced by man -t ssh > man_ssh.ps. It opens for viewing in Evince Document Viewer. I want to print it on a printer that supports double-sided printing. So, I'd like to print it in 'brochure' mode - that is, when four pages of a document are printed on two sides single sheet, so when the sheets are folded in half all at once, the numeration of the pages of a document is like in a booklet. How can I print the document this way in Evince?

UPD: There is one more question, how to make man -t output comply to booklet page layout - that is, wider inner margins, making pages 'left' and 'right'?

share|improve this question
    
+1. that's the only reason I sometimes have to resort to acroread –  type Jul 8 '11 at 7:02
2  
The only way I've found so far is to use psbook from psutils package. It will rearrange the pages in the input document, so they're in the booklet order in the output. However, it won't honor the page number caption position (they will appear on the same position, "left" or "right", not on "outer" or "inner"), since the input is already formatted by man. –  mbaitoff Jul 8 '11 at 8:32
1  
@type: Perhaps not, see my answer :-) –  krlmlr Jan 16 '13 at 16:28
add comment

2 Answers 2

I have found a way to configure CUPS so that it calls pdfbook for me. The process boils down to the following:

  1. In your CUPS server (e.g., http://localhost:631), create a copy of the configuration for the printer you want to enable brochure printing for. Let's call the new printer "Print-booklet".

  2. Edit /etc/cups/ppd/Print-booklet.ppd as root. Add the following line, e.g., before the *cupsFilter entry: *cupsPreFilter: "application/pdf 0 booklettopdf".

  3. (This step is a bit messy, perhaps it can be done in a cleaner way.) In /usr/lib/cups/filter, create the script booklettopdf (as root):

    #!/bin/sh
    for e in "$@"; do echo DEBUG: $0: $e 1>&2; done
    TMPFILE=$(mktemp)
    echo DEBUG: $0: $TMPFILE 1>&2
    if [ "$6" = "" ]; then
        cat
    else
        cat "$6"
    fi | pdfbook --scale 0.97 --outfile $TMPFILE && cat $TMPFILE && rm $TMPFILE
    
  4. Make the script executable: chmod +x booklettopdf.

  5. Print a test page.

Now, whenever you want to print in booklet format, choose the new printer "Print-booklet".

The cupsPreFilter is a CUPS PPD extension, and it seems that the application/pdf format will always appear in the filter chain (Ubuntu 12.10, perhaps earlier?).

I'd vote for integrating this functionality into CUPS.

share|improve this answer
    
In your script, if you use /bin/bash, everything after the first line can be replaced with this: cat "${6:-/dev/stdin}" | pdfbook --scale 0.97 --outfile /dev/stdout . Then you don't need any temporary file. –  Stefan Seidel Mar 1 '13 at 22:58
    
@StefanSeidel: For some reason I had trouble using pdfbook to print to stdout in the context of a filter. Don't remember the details, though. Does your code work for you? -- Note that printing a test page is different from printing from, say, evince. –  krlmlr Mar 1 '13 at 23:55
add comment
up vote 1 down vote accepted

Looks like currently there's no way to print pages in brochure (booklet) mode neither in Evince nor in Xpdf. There is a semi-solution to use psbook utility from the pstools package that will rearrange and output the pages in the postscript file so they go as in booklet mode. Please note the -s option of the psbook which controls the number of original pages that would go into one booklet. This is useful when you want to print large amount of pages that is not going to be folded all at once, but folded into several sub-booklets. For example, 120-page document would go into 30-sheet brochure by default, which is hard to fold. Using the psbook -s 24 will make 120/24=5 brochures 6 sheets each, which are easy to fold and then to combine together.

Also note that man -t output is not well prepared for booklet printing - it has page numbers on "right" side, not on the "outer" side, and "left" and "right" page margins are the same instead of "inner" margin being larger than "outer", and pages are not classified as "left" and "right". Discussion on how to tweak the man -t output goes here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.