Sometimes I print two sided documents. Therefore I first print odd pages then I use the same papers in reverse order to print even pages(I just check reverse while printing).

I do this operation manually, it means that I enter page numbers my self, like: 1,3,5,7,9 for odd pages then 2,4,6,8,10 for even pages.

The problem is when I want to print a large number of pages this is hard to do. Imagine 100 pages. Moreover I may make some mistakes in between.

Is there any way to define odd pages in general print dialog of ubuntu?

I am using Ubuntu 12.10 with default hplib for printing.

  • This might depend on the printer... so make/model/brand might be useful. And it might also be depending on the software you use.
    – Rinzwind
    Apr 15, 2013 at 7:21
  • My printer is HP LaserJet 1018. I use the hplib for printing. The one which is shipped with Ubuntu 12.10.
    – mehdix
    Apr 15, 2013 at 7:24

3 Answers 3


If you're trying to print from libreoffice, there is an option to print left or right pages only.

Open the print dialog, then choose tle layout tab and choose the appropriate option under the page sides dropdown.

If you're printing a pdf, Document viewer has a similar option under the page setup tab of the print dialog box.

  • 1
    No, I'm trying to pring pdf files. I view pdf files using Document-Viwer.
    – mehdix
    Apr 15, 2013 at 17:44
  • Thanks, worked fine. But I can not still vote up!
    – mehdix
    Apr 15, 2013 at 17:58
  • 1
    I gained voting privilege today.
    – mehdix
    Oct 26, 2013 at 18:29
  • 3
    For printing pdf files with Document Viewer, the option in the Print dialog box is (as you said) in the Page Setup tab, and is called Only print, with values All sheets, Even sheets and Odd sheets May 25, 2014 at 12:47

you could also do this from the command-line using the lp command:

$ PDF_NAME='my_document.pdf'

# print odd pages
$ lp "${PDF_NAME}" -P $(seq -s ',' 1 2 "${NUMBER_PAGES}")

# print even pages:
$ lp "${PDF_NAME}" -P $(seq -s ',' 2 2 "${NUMBER_PAGES}") -o outputorder=reverse
# may have to add '-o orientation-requested=6' to rotate by 180°

the seq commands just output the comma-separated list of pages as needed for the lp command:

$ seq -s ',' 1 2 "${NUMBER_PAGES}"  # -> 1,3,5,7,9,11,13,15
$ seq -s ',' 2 2 "${NUMBER_PAGES}"  # -> 2,4,6,8,10,12,14

the commands above will print to the default printer if you have one defined. otherwise you will need to find the printer name and specify it on the command line:

# find the available printers and the default printer:
$ lpstat -p -d
# printer my_printer is idle. enabled since ...

# direct lp to use the desired printer
$ lp -d my_printer ...

if you need to get the number of pages automatically (there may be a nicer way to do this) you could use pdfinfo from the poppler-utils package:

$ NUMBER_PAGES=$(pdfinfo "${PDF_BOOK}" | grep 'Pages:' | cut -d ':' -f 2 | xargs)

Based on hiro protagonist answer, I am trying to save everyone working out the details to make a function out of it.

Run lpstat -p -d to find your printer's name and replace printer_name with the name of your printer in the below scripts.

Once the below functions are saved in ~/.bashrc or ~/.zshrc or similar, they can be invoked as a command from the shell like:

printOdd <file>

printEven <file>

function printOdd() {
  NUMBER_PAGES=$(pdfinfo $1 | grep 'Pages:' | cut -d ':' -f 2 | xargs)
  lp "$1" -P $(seq -s ',' 1 2 "${NUMBER_PAGES}") -d printer_name

function printEven() {
  NUMBER_PAGES=$(pdfinfo $1 | grep 'Pages:' | cut -d ':' -f 2 | xargs)
  lp "$1" -P $(seq -s ',' 2 2 "${NUMBER_PAGES}") -d printer_name

PS: You need to have pdfinfo installed in your system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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