Server-side events in DocuVieware
DocuVieware provides three server-side events that enable you to respond to user actions and document operations. All three events are accessible through the dedicated DocuViewareEventsHandler class.
Available events
DocuVieware provides the following server-side events:
NewDocumentLoaded— Triggered when a new document is loaded into the viewer.CustomAction— Triggered when a custom action is invoked from the client side.PageTransferReady— Triggered when a page is ready to be transferred to the client.
Setting up event subscriptions
Start your applications by setting up the configuration and registering your license key. Register event subscriptions after this initial setup.
The following example shows how to configure DocuVieware and subscribe to the NewDocumentLoaded event:
// In your application startup code (for example, Application_Start in Global.asax.cs):DocuViewareManager.SetupConfiguration(true, DocuViewareSessionStateMode.InProc, "\\Cache");DocuViewareLicensing.RegisterKEY("XXXX"); // Replace with your license keyDocuViewareEventsHandler.NewDocumentLoaded += NewDocumentLoadedHandler;This registers the NewDocumentLoadedHandler function to run when a new document is loaded. The same pattern applies for other events, but with different event arguments.
Example: Dynamic page preloading
This example demonstrates how to change the PagePreload property based on the number of pages in a loaded document.
The goal is to preload every page if the document has fewer than 20 pages, but only preload adjacent pages for larger documents:
private static void NewDocumentLoadedHandler(object sender, NewDocumentLoadedEventArgs e){ e.docuVieware.PagePreload = e.docuVieware.PageCount <= 20 ? PagePreloadMode.AllPages : PagePreloadMode.AdjacentPages;}Every event arguments object contains the corresponding
DocuViewareobject, along with other elements specific to the event type. This enables you to perform any operation on the control and the document it contains.For a practical example, refer to the barcode recognition demo.
Related APIs
DocuViewareEventsHandlerclassCustomActioneventNewDocumentLoadedeventPageTransferReadyeventCustomActionEventArgsclassNewDocumentLoadedEventArgsclassPageTransferReadyEventArgsclass