Observing Changes with Events
PSPDFKit for Web comes with an API to subscribe and unsubscribe to framework-level events that are dispatched every time actions occur. This API is available on every
Instance and consists of two methods:
A comprehensive list of and detailed documentation for every event is available in the
Once PSPDFKit for Web is initialized, registering an event listener is straightforward:
It is important to define the
listener function separately so that it can be used later on to remove the event listener:
Please note that adding an unknown event will raise a
With the exception of exact single-value arguments like numbers and strings, PSPDFKit for Web invokes event listeners with immutable data structures. When this occurs, you can use the
Registering Events on the Internal Viewer
PSPDFKit for Web is rendered inside of an iframe, and because of this, we expose its
window objects on each instance as
By using a reference to these objects, it is possible to register regular DOM events on elements inside of the viewer frame:
As a general rule, we advise against registering events on the objects, since this might easily interfere with internal application logic. When possible, please use PSPDFKit for Web events.
Event Examples and Documentation
All of the available events are documented, with examples, on the documentation page for PSPDFKit.Instance. Please don’t hesitate to contact us if specific use cases are not covered in the API docs.