Skip to content

Commit 5a10376

Browse files
authored
Merge pull request #20191 from calixteman/link_gotoxy
Add a method goToXY in PDFLinkService in order to scroll the document at a given location
2 parents 261c1f9 + 1678782 commit 5a10376

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

web/interfaces.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ class IPDFLinkService {
7373
*/
7474
goToPage(val) {}
7575

76+
/**
77+
* Scrolls to a specific location in the PDF document.
78+
* @param {number} pageNumber - The page number to scroll to.
79+
* @param {number} x - The x-coordinate to scroll to in page coordinates.
80+
* @param {number} y - The y-coordinate to scroll to in page coordinates.
81+
*/
82+
goToXY(pageNumber, x, y) {}
83+
7684
/**
7785
* @param {HTMLAnchorElement} link
7886
* @param {string} url

web/pdf_link_service.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,20 @@ class PDFLinkService {
239239
this.pdfViewer.scrollPageIntoView({ pageNumber });
240240
}
241241

242+
/**
243+
* Scrolls to a specific location in the PDF document.
244+
* @param {number} pageNumber - The page number to scroll to.
245+
* @param {number} x - The x-coordinate to scroll to in page coordinates.
246+
* @param {number} y - The y-coordinate to scroll to in page coordinates.
247+
*/
248+
goToXY(pageNumber, x, y) {
249+
this.pdfViewer.scrollPageIntoView({
250+
pageNumber,
251+
destArray: [null, { name: "XYZ" }, x, y],
252+
ignoreDestinationZoom: true,
253+
});
254+
}
255+
242256
/**
243257
* Adds various attributes (href, title, target, rel) to hyperlinks.
244258
* @param {HTMLAnchorElement} link

0 commit comments

Comments
 (0)