Implementation of force-page-count property, patch by Gerhard Oettl, somewhat rearranged by me. See bug 38087.