diff --git a/web/interfaces.js b/web/interfaces.js index 620d571de..7c926af9c 100644 --- a/web/interfaces.js +++ b/web/interfaces.js @@ -73,6 +73,14 @@ class IPDFLinkService { */ 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 {string} url diff --git a/web/pdf_link_service.js b/web/pdf_link_service.js index a2cb46245..9f46a0475 100644 --- a/web/pdf_link_service.js +++ b/web/pdf_link_service.js @@ -239,6 +239,20 @@ class PDFLinkService { 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. * @param {HTMLAnchorElement} link