Skip to content

Commit

Permalink
Fix negative page index issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed May 28, 2024
1 parent c91890e commit 461ebf3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/module/content-rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function getLinesFromChars(chars) {
export async function getContentRect(pdfDocument, structuredCharsProvider) {
let numPages = pdfDocument.catalog.numPages;
let pageIndex = Math.floor(numPages / 2);
let startPage = pageIndex - 2;
let endPage = pageIndex + 2;
let startPage = Math.max(pageIndex - 2, 0);
let endPage = Math.min(pageIndex + 2, numPages - 1);

let x;

Expand Down

0 comments on commit 461ebf3

Please sign in to comment.