30th October 2008
There are several ways to do that, I’ll describe the one which worked for me. Please note, that printing from CLI has an advantage of being able to print out something at work from the comfort of your home and ssh (provided that the printer is on and is loaded with paper).
To extract a single page (or a range of pages), I used pdftops:
pdftops -f 187 -l 187 -paper A4 abstract_book.pdf page_187.ps
Here, -f is the first page, -l is the last, and -paper is paper size.
Alternatives include using pdf2ps (which relies on GhostScript and accepts the same options) and acroread -toPostScript (which uses non-free Adobe Reader in CLI mode to convert PDF to PS).
Now that I have a single-page PS file, I can print it:
cupsdoprint -P S200 -o Resolution=720dpi,Copies=2,PageSize=A4 page_187.ps
Printing options will vary depending on your printer model (use lpoptions -l -P PrinterName to find out possible options and their default values). In the sample line above, S200 is the printer to use for printing, Resolution/Copies/PageSize are all self-explanatory printing options.
Alternative (and, actually, more standard) way to print is by using lpr, but if you run CUPS and KDE then cupsdoprint isn’t any worse.
For more details this FAQ might be helpful. Also, keep in mind that simple shell scripts can automate routine sequential tasks, and that piping helps.