How to print only even or odd pages (HP LaserJet 1018)
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.
you could also do this from the command-line using the lp
command:
$ PDF_NAME='my_document.pdf'
$ NUMBER_PAGES=15
# 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:
$ NUMBER_PAGES=15
$ 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)