Skip to content

Commit 4c05044

Browse files
committed
[Debugger] Allow debugging page-rendering from the /Ref, in addition to the pageNumber
Currently it's only possible to trigger page-render debugging through the page number, but when looking at the /Pages tree it's often not immediately obvious what the page number actually is. However, the /Ref of the page is directly available and it's thus handy to be able to use that one instead to enable page-render debugging.
1 parent e577141 commit 4c05044

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

web/internal/debugger.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ gotoInput.addEventListener("keydown", async ({ key, target }) => {
230230
return;
231231
}
232232
target.removeAttribute("aria-invalid");
233+
234+
// Allow debugging via references, as well as page numbers.
235+
if (result.page === undefined) {
236+
try {
237+
result.page =
238+
pdfDoc.cachedPageNumber(result.ref) ??
239+
(await pdfDoc.getPageIndex(result.ref)) + 1;
240+
} catch {}
241+
}
233242
// If we're in debug view and navigating to a page, stay in debug view
234243
// without switching to the tree at all.
235244
if (!debugViewEl.hidden && result.page !== undefined) {

0 commit comments

Comments
 (0)