Printable A5 booklet on A4 sheets from A5 pages using psutils, pstops and CUPS

cupsduplexpostscriptprinting

I want to create a CUPS printer queue which accepts books with A5 pages and automatically arranges them as booklets on A4 paper before printing them. Essentially, this is done wonderfully using the following pipe:

psbook -s4 | psnup -Pa5 -pa4 -2

I've created a CUPS queue that uses this pipe and everything works perfectly, the pages are arranged and printed exactly as I want to, except that the output from psnup confuses my printer and duplexing options are ignored (possibly debian bug 168954). I've found claims on the web that psutils is broken which offer a workaround, but since I do not understand how the workaround is supposed to be used, I'm trying to replicate the behaviour psbook and psnup with other tools (pstops and mpage for now).

The problem is that all instructions on making booklets on the web assume that I have A4 pages which I want to scale down to A5 and turn into a booklet, and unfortunately I'm not doing anything so insane. I want something more simpler – take the A5 pages and arrange them over the A4 pages. The question is how?

I came up with the following pagespec for pstops which downscales the A4 pages:

4:3L@0.7(21cm,0)+0L@0.7(21cm,14.85cm),1L@0.7(21cm,0)+2L@0.7(21cm,14.85cm)

And if I upscale my A5 pages to A4 beforehand, it works. Unfortunately, everything is slightly off (the scale, the borders), and I cannot modify the pagespec to correctly position the A5 pages.

I tried placing the A5 page in the middle of an A4 page and use scale @1, but when I adjust the offsets, my text gets cropped anyway.

And mpage seems to be designed for scaling only, I couldn't find any way to force it not to scale.

P.S. I checked that the resulting postscript file contains all duplex settings right before arriving at the printer, although CUPS adds some of them twice (because the printing goes through two queues)

Best Answer

Start with an A5 PDF file with the pages in sequence. Turn the following into a pipeline script:

pdftops FILE.pdf FILE.ps
psbook -q FILE.ps FILE_BOOK.ps
psnup -q -la4 -pa4 -Pa5 -2 FILE_BOOK.ps FILE_SIG.ps
ps2pdf FILE_SIG.ps

That should give you a FILE_SIG.pdf.

Note: FILE_SIG.ps looks wrong but prints correctly. Changing it to a PDF saves space and displays correctly.

Now all you have to do is get your printer to print out the sheets back to back without screwing up.

Related Question