From 2606066103df4e1583f45acc0899e8e3a47f052f Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 19 Jan 2026 16:57:34 +0100 Subject: [PATCH] Add logging for page changes and total pages in PSPDFKit Added a .then() handler to loadPSPDFKit to log the active page number on page change events and log the total number of pages after loading. This aids in debugging and tracking user navigation within the document. --- EnvelopeGenerator.Web/wwwroot/js/ui.js | 11 ++++++++++- EnvelopeGenerator.Web/wwwroot/js/ui.min.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/EnvelopeGenerator.Web/wwwroot/js/ui.js b/EnvelopeGenerator.Web/wwwroot/js/ui.js index fdf97f15..cae28f04 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/ui.js +++ b/EnvelopeGenerator.Web/wwwroot/js/ui.js @@ -16,7 +16,16 @@ isEditableAnnotation: function (annotation) { return !(annotation.isSignature || annotation.description === 'FRAME') }, - }); + }).then((instance) => { + instance.addEventListener('viewState.currentPageIndex.change', (pageIndex) => { + console.log('Active page:', pageIndex + 1) + }) + + const totalPages = instance.totalPageCount || 0 + console.log('All pages loaded, total pages:', totalPages) + + return instance + }) } const allowedToolbarItems = [ diff --git a/EnvelopeGenerator.Web/wwwroot/js/ui.min.js b/EnvelopeGenerator.Web/wwwroot/js/ui.min.js index 3a33bbf6..06610632 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/ui.min.js +++ b/EnvelopeGenerator.Web/wwwroot/js/ui.min.js @@ -1,4 +1,4 @@ -function loadPSPDFKit(n,t,i,r){return PSPDFKit.load({inlineWorkers:!1,locale:r,licenseKey:i,styleSheets:["/css/site.css"],container:t,document:n,annotationPresets:getPresets(),electronicSignatures:{creationModes:["DRAW","TYPE","IMAGE"]},initialViewState:new PSPDFKit.ViewState({sidebarMode:PSPDFKit.SidebarMode.THUMBNAILS}),isEditableAnnotation:function(n){return!(n.isSignature||n.description==="FRAME")}})}function addToolbarItems(n,t){var i=n.toolbarItems.filter(n=>allowedToolbarItems.includes(n.type));i=IS_READONLY?i.concat(getReadOnlyItems(t)):i.concat(getWritableItems(t));IS_DESKTOP_SIZE||IS_READONLY||(i=i.concat(getMobileWritableItems(t)));n.setToolbarItems(i)}function getWritableItems(n){return[{type:"custom",id:"button-share",className:"button-share",title:"Teilen",onPress(){n("SHARE")},icon:` +function loadPSPDFKit(n,t,i,r){return PSPDFKit.load({inlineWorkers:!1,locale:r,licenseKey:i,styleSheets:["/css/site.css"],container:t,document:n,annotationPresets:getPresets(),electronicSignatures:{creationModes:["DRAW","TYPE","IMAGE"]},initialViewState:new PSPDFKit.ViewState({sidebarMode:PSPDFKit.SidebarMode.THUMBNAILS}),isEditableAnnotation:function(n){return!(n.isSignature||n.description==="FRAME")}}).then(n=>{n.addEventListener("viewState.currentPageIndex.change",n=>{console.log("Active page:",n+1)});const t=n.totalPageCount||0;return console.log("All pages loaded, total pages:",t),n})}function addToolbarItems(n,t){var i=n.toolbarItems.filter(n=>allowedToolbarItems.includes(n.type));i=IS_READONLY?i.concat(getReadOnlyItems(t)):i.concat(getWritableItems(t));IS_DESKTOP_SIZE||IS_READONLY||(i=i.concat(getMobileWritableItems(t)));n.setToolbarItems(i)}function getWritableItems(n){return[{type:"custom",id:"button-share",className:"button-share",title:"Teilen",onPress(){n("SHARE")},icon:` `},{type:"custom",id:"button-logout",className:"button-logout",title:"logout",onPress(){n("LOGOUT")},icon:`