// you can put anywhere in viewer.js (pdfjs/web/viewer.js) and listens to it const event = document.createEvent("CustomEvent"); event.initCustomEvent("your_new_event", true, true, {}); document.dispatchEvent(event);