Add a method goToXY in PDFLinkService in order to scroll the document at a given location

This function is required for the commenting feature: the user will be able to click
on a comment in the sidebar and the document will be scrolled accordingly.
This commit is contained in:
Calixte Denizet 2025-08-24 21:02:02 +02:00
parent 649a03f817
commit 1678782680
2 changed files with 22 additions and 0 deletions

View File

@ -73,6 +73,14 @@ class IPDFLinkService {
*/ */
goToPage(val) {} goToPage(val) {}
/**
* Scrolls to a specific location in the PDF document.
* @param {number} pageNumber - The page number to scroll to.
* @param {number} x - The x-coordinate to scroll to in page coordinates.
* @param {number} y - The y-coordinate to scroll to in page coordinates.
*/
goToXY(pageNumber, x, y) {}
/** /**
* @param {HTMLAnchorElement} link * @param {HTMLAnchorElement} link
* @param {string} url * @param {string} url

View File

@ -239,6 +239,20 @@ class PDFLinkService {
this.pdfViewer.scrollPageIntoView({ pageNumber }); this.pdfViewer.scrollPageIntoView({ pageNumber });
} }
/**
* Scrolls to a specific location in the PDF document.
* @param {number} pageNumber - The page number to scroll to.
* @param {number} x - The x-coordinate to scroll to in page coordinates.
* @param {number} y - The y-coordinate to scroll to in page coordinates.
*/
goToXY(pageNumber, x, y) {
this.pdfViewer.scrollPageIntoView({
pageNumber,
destArray: [null, { name: "XYZ" }, x, y],
ignoreDestinationZoom: true,
});
}
/** /**
* Adds various attributes (href, title, target, rel) to hyperlinks. * Adds various attributes (href, title, target, rel) to hyperlinks.
* @param {HTMLAnchorElement} link * @param {HTMLAnchorElement} link