Defining a custom Content Handler
Many customers create a custom content handler class that integrates with their document management and security systems.
The Content Handler APIs are now documented in our Javadocs located on our website VirtualViewer Documentation - Content Handler API.
Once you have created your custom content handler and place it in VirtualViewer’s Java classpath you can specify its location via the contentHandlerClass
parameter. It can be found in the web.xml
file in the WEB-INF folder.
<init-param>
<param-name>contentHandlerClass</param-name>
<param-value>com.mycompany.viewer.DocumentContentHandler</param-value>
</init-param>
VirtualViewer would then look for and invoke your custom content handler at ./WEB-INF/com/mycompany/viewer/DocumentContentHandler.class.
Using the Sample FileContentHandler
Packaged with VirtualViewer® is a source code sample for a basic fileContentHandler. It can be found in the VirtualViewer Java v5.11.0\sample-code\Java Content Handler
folder. It is provided as a starting point for your own content handler and not meant for use in production.
Notes for Starting your custom FileContentHandler
ContentHandlerInput and ContentHandlerResult
Every public Content Handler method accepts ContentHandlerInput and returns ContentHandlerResult
ContentHandlerInterface
The ContentHandlerInterface must be implemented in your custom FileContentHandler.
Additional interfaces
You can use additional Content Handler Interfaces to make use of more features in VirtualViewer®.
RESTful Content Handler Project Sample
VirtualViewer® HTML5 Ships with a RESTful content handler that provides a more flexible development and deployment process for customers.
Packaged in the latest version is a small Express server as a test/example for use with the RESTful content handler proof of concept. The content handler will call out to a server with RESTful http API calls, and this server will provide documents, annotations, notes, etc.
You will find this project in the sample-code/RESTful Content Handler Server Example folder of the VirtualViewer® build. Please be sure to read the README.md for the most up to date instructions.
Have questions, corrections, or concerns about this topic? Please let us know!