Merge pull request #20191 from calixteman/link_gotoxy

Add a method goToXY in PDFLinkService in order to scroll the document at a given location
This commit is contained in:
calixteman 2025-08-25 20:08:03 +02:00 committed by GitHub
commit 5a10376e4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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