Backport of #11524 into stable7

Page size calculation based on real page height.

cherry-picked from 08582d1