Readonly numerical property printer.toPage contains the index of the last page to print. Use function printer:setFromTo to change it.
printer.toPage
printer:setFromTo