Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to send a PDF file (or files) to the printer via the command line, but print only, say, odd-numbered pages? E.g., lpr -{some option} *.pdf Or perhaps {some command to get odd-numbered pages} *.pdf | lpr. This would be faster than opening each file, opening the Print dialogue, and telling it to print pages 1, 3, 5, 7, 9... The idea is to print all odd pages, then I can print the even numbered pages on the other side of the paper.

share|improve this question
add comment

3 Answers

Try

lpr -o page-set=odd <file>
lpr -o page-set=even <file>

You can find the documentation of this and other lpr options in the cups documentation.

share|improve this answer
    
@ fschmitt : Thanks, that worked perfectly! (Sorry, I can't figure out how to comment instead of leaving a whole answer.) –  Wolf Oct 18 '10 at 12:53
add comment

An alternative to the cups solution by fschmitt - for example if you only have some limited lpr available - is the command psselect.

For example for manual duplex printing in a printer without a duplex unit:

$ psselect -e -r < foo.ps | lpr
$ # manually rotate pages by 180 degrees and reinsert
$ psselect -o < foo.ps | lpr

Well, only works if your printer has a rock solid paper transport mechanism ...

-e selects only the even pages, -o odd ones, and -r reverses the selection

share|improve this answer
add comment

If you choose to preprocess the PDF (for example because your printing framework is not CUPS and doesn't support page selection), you can do it with pdftk.

pdftk A=foo.pdf cat Aodd output - | lpr
# take out the sheets and feed them back in
pdftk A=foo.pdf cat Bend-1even output - | lpr

Depending on how cheap your printer is, you may need to print the odd pages in reverse and the even pages in order: move end-1 to the other command. If the document has an odd number of pages, take out the last page from the stack and don't feed it back in the second time.

share|improve this answer
    
Hm, about the paper burning - the duplex models of HP printers I've come across always did some automatic re-inserting of the page to print on the backside, they did not print both sides at once. –  maxschlepzig Oct 18 '10 at 9:21
    
@maxschlepzig: Yes, you're right, I've been overgeneralizing a valid point. Printing on the back of a sheet that's been around and has accumulated some bad stuff (specks of dirt, inkjet ink, small tears, …) could damage the paper or the printer, but reinserting the paper as it comes out of the printer for the first time is fine. –  Gilles Oct 18 '10 at 10:38
add comment

Your Answer

 
discard

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