Fixes issue 3076 (viewer off by one page)

As the title says, this fixes #3076.

Edit: This PR only fixes the second issue described in the attached PDF file in #3076.
The third issue behaves the same way in pdf.js and Adobe Reader, so this must be an error in the PDF file.