public class FileContentHandler extends Object implements VirtualViewerContentHandlerInterface, AvailableDocumentsInterface, AllAnnotationsInterface, AnnotationsInterface, BookmarksInterface, CreateDocumentInterface, DocumentNotesInterface, EventSubscriberInterface, SendDocumentInterface, WatermarksInterface
PERM_CREATE, PERM_DELETE, PERM_EDIT, PERM_HIDDEN, PERM_PRINT, PERM_PRINT_WATERMARK, PERM_REDACTION, PERM_VIEW, PERM_VIEW_WATERMARK
Constructor and Description |
---|
FileContentHandler() |
Modifier and Type | Method and Description |
---|---|
ContentHandlerResult |
createDocument(ContentHandlerInput input) |
ContentHandlerResult |
deleteAnnotation(ContentHandlerInput input)
Called when the client has requested to delete the specified annotation layer.
|
ContentHandlerResult |
deleteBookmarkContent(ContentHandlerInput input)
Delete the bookmark XML content for the specified document key, if it exists.
|
ContentHandlerResult |
deleteNotesContent(ContentHandlerInput input)
Called when the client has requested to delete all notes for the specified document.
|
ContentHandlerResult |
deleteWatermarkContent(ContentHandlerInput input)
Delete the watermark content for the specified document key, if it exists.
|
ContentHandlerResult |
eventNotification(ContentHandlerInput input)
This method is called when some events occur in the VirtualViewer client, such as opening a document or viewing a
new page on the document.
|
ContentHandlerResult |
getAllAnnotationsForDocument(ContentHandlerInput input)
Returns a map of all of the annotations for a specified document key.
|
ContentHandlerResult |
getAnnotationContent(ContentHandlerInput input)
Returns the content for the specified annotation layer and document key in the form of a
byte array.
|
ContentHandlerResult |
getAnnotationContentFromFile(ContentHandlerInput input) |
ContentHandlerResult |
getAnnotationNames(ContentHandlerInput input)
Returns an array of annotation layer names for the specified
document key and client instance key.
|
ContentHandlerResult |
getAnnotationProperties(ContentHandlerInput input)
Returns the properties for a specified annotation layer key in the form
of a hashtable.
|
ContentHandlerResult |
getAvailableDocumentIds(ContentHandlerInput input)
Returns an array containing the set of document keys available for viewing.
|
ContentHandlerResult |
getBookmarkContent(ContentHandlerInput input)
Returns the bookmark XML content for the specified document key in the
form of a byte array.
|
ContentHandlerResult |
getDocumentContent(ContentHandlerInput input)
Returns the content for the specified document key.
|
ContentHandlerResult |
getDocumentContentByFile(ContentHandlerInput input) |
ContentHandlerResult |
getNotesContent(ContentHandlerInput input)
Returns the contents of the document notes XML file for the specified document key in the
form of a byte array.
|
ContentHandlerResult |
getWatermarkContent(ContentHandlerInput input)
Returns the watermark file for the specified document key in the form of a byte array.
|
void |
init(javax.servlet.ServletConfig config)
Used to set up each content handler instance before any methods are called.
|
ContentHandlerResult |
saveAnnotationContent(ContentHandlerInput input)
This method gets called when annotation data for the specified
annotation file is ready to be saved.
|
ContentHandlerResult |
saveAnnotationContent(javax.servlet.http.HttpServletRequest request,
String clientInstanceId,
String documentKey,
String annotationKey,
int pageSpecificIndex,
byte[] data,
Map annProperties) |
ContentHandlerResult |
saveDocumentComponents(ContentHandlerInput input)
This method is used to save or update an existing document and sub-components of the document, such as annotations,
bookmarks, document notes and watermarks.
|
ContentHandlerResult |
saveDocumentComponentsAs(ContentHandlerInput input)
This method is used to save a copy of a document under a new key, along with sub-components of the document, such
as annotations, bookmarks, document notes and watermarks.
|
ContentHandlerResult |
saveDocumentContent(ContentHandlerInput input)
This method is used to update document data only.
|
ContentHandlerResult |
sendDocumentContent(ContentHandlerInput input)
This method gets called to send a document via a mechanism defined by the content handler.
|
static void |
setFilePath(String pathParam,
javax.servlet.ServletContext context) |
static void |
setSupportsTiffTagAnnotations(boolean pValue) |
public void init(javax.servlet.ServletConfig config) throws VirtualViewerAPIException
VirtualViewerContentHandlerInterface
init
in interface VirtualViewerContentHandlerInterface
config
- The ServletConfig object for the VirtualViewer server. Can be used to retrieve web.xml parameters.VirtualViewerAPIException
- if content handler throws exceptionpublic static void setFilePath(String pathParam, javax.servlet.ServletContext context)
public ContentHandlerResult getAnnotationNames(ContentHandlerInput input) throws VirtualViewerAPIException
AnnotationsInterface
Example:
public ContentHandlerResult getAnnotationNames(ContentHandlerInput input)
throws VirtualViewerAPIException
{
String clientInstanceId = input.getClientInstanceId();
String documentKey = input.getDocumentId();
String[] arrayNames = new String[2];
arrayNames[0] = "layerOne";
arrayNames[1] = "layerTwo";
ContentHandlerResult result = new ContentHandlerResult();
result.put(ContentHandlerResult.KEY_ANNOTATION_NAMES, arrayNames);
return result;
}
getAnnotationNames
in interface AnnotationsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_NAMES | java.lang.String[] | An array of all the annotation layer keys for the document. |
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorAnnotationsInterface.getAnnotationNames(ContentHandlerInput)
public ContentHandlerResult saveAnnotationContent(ContentHandlerInput input) throws VirtualViewerAPIException
AnnotationsInterface
saveAnnotationContent
in interface AnnotationsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_ID | java.lang.String | The key for the annotation layer to be saved. Can be retrieved with . |
KEY_ANNOTATION_CONTENT | byte[] | Annnotation data to be saved. Can be retrieved with . |
KEY_ANNOTATION_PROPERTIES | java.util.Hashtable | Map of annotation properties to be saved. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorAnnotationsInterface.saveAnnotationContent(ContentHandlerInput)
public ContentHandlerResult saveAnnotationContent(javax.servlet.http.HttpServletRequest request, String clientInstanceId, String documentKey, String annotationKey, int pageSpecificIndex, byte[] data, Map annProperties) throws VirtualViewerAPIException
VirtualViewerAPIException
public ContentHandlerResult saveDocumentComponents(ContentHandlerInput input) throws VirtualViewerAPIException
VirtualViewerContentHandlerInterface
saveDocumentComponents
in interface VirtualViewerContentHandlerInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_CONTENT | byte[] |
The document file content. If null no changes need to be saved to the document.
Can be retrieved with .
|
KEY_ANNOTATION_LAYERS | com.snowbound.common.transport.AnnotationLayer[] |
All of the annotation layers for the document. Each layer should be updated if it layer.isNew() or
isModified() is true, and if a layer has been saved but is no longer present in the array it should be deleted.
Can be retrieved with .
|
KEY_BOOKMARK_CONTENT | byte[] |
The bookmark file content. If null no changes need to be saved to the bookmark file.
Can be retrieved with .
|
KEY_NOTES_CONTENT | byte[] |
The notes file content. If null no changes need to be saved to the notes file.
Can be retrieved with .
|
KEY_WATERMARK_CONTENT | byte[] |
The watermark file content. If null no changes need to be saved to the watermark file.
Can be retrieved with .
|
KEY_PAGE_COUNT | int | The number of pages in the document. Can be retrieved with . |
KEY_DOCUMENT_FORMAT | int |
An integer code representing the document format. Can be retrieved along with a format information object with the following code:
|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
DOCUMENT_ID_TO_RELOAD | String | Optional return used to alert the client that the document key has been changed when saving. This could be used if the content handler decided to create a new document under a new key instead of updating the original document. |
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorVirtualViewerContentHandlerInterface.saveDocumentComponents(ContentHandlerInput)
public ContentHandlerResult saveDocumentComponentsAs(ContentHandlerInput input) throws VirtualViewerAPIException
VirtualViewerContentHandlerInterface
saveDocumentComponentsAs
in interface VirtualViewerContentHandlerInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_CONTENT | byte[] |
The document file content. If null no changes need to be saved to the document.
Can be retrieved with .
|
KEY_ANNOTATION_LAYERS | com.snowbound.common.transport.AnnotationLayer[] |
All of the annotation layers for the document. If not null all layers should be saved for the
new document.
Can be retrieved with .
|
KEY_BOOKMARK_CONTENT | byte[] |
The bookmark file content. If null no bookmark file need be saved.
Can be retrieved with .
|
KEY_NOTES_CONTENT | byte[] |
The notes file content. If null no notes file need be saved.
Can be retrieved with .
|
KEY_WATERMARK_CONTENT | byte[] |
The watermark file content. If null no watermark file need be saved.
Can be retrieved with .
|
KEY_PAGE_COUNT | int | The number of pages in the document. Can be retrieved with . |
KEY_DOCUMENT_FORMAT | int |
An integer code representing the document format. Can be retrieved along with a format information object with the following code:
|
KEY_DOCUMENT_ID | java.lang.String | A temporary key based on the original document's display name. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
DOCUMENT_ID_TO_RELOAD | String | Optional return used to alert the client that the document key has been changed when saving. VirtualViewer will send a temporary document key in the input based on the original document's display name, but if that is being changed then this return value should be set. |
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorVirtualViewerContentHandlerInterface.saveDocumentComponentsAs(ContentHandlerInput)
public ContentHandlerResult createDocument(ContentHandlerInput input) throws VirtualViewerAPIException
createDocument
in interface CreateDocumentInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_CONTENT | byte[] | The new document's data to be saved. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key the new document should be saved under. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorCreateDocumentInterface.createDocument(com.snowbound.contenthandler.ContentHandlerInput)
public ContentHandlerResult saveDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException
VirtualViewerContentHandlerInterface
saveDocumentContent
in interface VirtualViewerContentHandlerInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_CONTENT | byte[] | The document file content. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
DOCUMENT_ID_TO_RELOAD | String | Optional return used to alert the client that the document key has been changed when saving. This could be used if the content handler decided to create a new document under a new key instead of updating the original document. |
VirtualViewerAPIException
- if content handler throws exceptionVirtualViewerContentHandlerInterface.saveDocumentContent(ContentHandlerInput)
public ContentHandlerResult getAnnotationContent(ContentHandlerInput input) throws VirtualViewerAPIException
AnnotationsInterface
Example:
// This example retrieves the annotation layer data from the local filesystem. The annotation file is assumed to
// be in a file named with the form <documentKey>.<annotationLayerKey>.ann.
public ContentHandlerResult getAnnotationContent(ContentHandlerInput input)
throws VirtualViewerAPIException
{
String clientInstanceId = input.getClientInstanceId();
String documentKey = input.getDocumentId();
String annotationKey = input.getAnnotationId();
String annotationFilename = documentKey + "." + annotationKey + ".ann";
String fullFilePath = gFilePath + annotationFilename;
try
{
File file = new File(fullFilePath);
byte[] bytes = getFileBytes(file);
ContentHandlerResult result = new ContentHandlerResult();
result.put(ContentHandlerResult.KEY_ANNOTATION_CONTENT, bytes);
return result;
}
catch (IOException e)
{
return null;
}
}
getAnnotationContent
in interface AnnotationsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_ID | java.lang.String | The key for the requested annotation layer. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_CONTENT | byte[] | Contents of the annotation layer file. |
VirtualViewerAPIException
- if content handler throws exceptionAnnotationsInterface.getAnnotationContent(ContentHandlerInput)
public ContentHandlerResult getAnnotationContentFromFile(ContentHandlerInput input) throws VirtualViewerAPIException
VirtualViewerAPIException
public ContentHandlerResult getAnnotationProperties(ContentHandlerInput input) throws VirtualViewerAPIException
AnnotationsInterface
getAnnotationProperties
in interface AnnotationsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_ID | java.lang.String | The key for the requested annotation layer. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_PROPERTIES | java.util.Hashtable | Map of the specified annotation layer's properties |
VirtualViewerAPIException
- if content handler throws exceptionAnnotationsInterface.getAnnotationProperties(ContentHandlerInput)
public ContentHandlerResult getBookmarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
BookmarksInterface
getBookmarkContent
in interface BookmarksInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_BOOKMARK_CONTENT | byte[] | Contents of the bookmark XML file, or null if no bookmarks are associated with the given document. |
VirtualViewerAPIException
- if content handler throws exceptionBookmarksInterface.getBookmarkContent(ContentHandlerInput)
public ContentHandlerResult deleteBookmarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
BookmarksInterface
deleteBookmarkContent
in interface BookmarksInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorBookmarksInterface.deleteBookmarkContent(com.snowbound.contenthandler.ContentHandlerInput)
public ContentHandlerResult getWatermarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
WatermarksInterface
getWatermarkContent
in interface WatermarksInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_WATERMARK_CONTENT | byte[] | Contents of the watermark file for this document, or null if no watermarks have been saved. |
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorWatermarksInterface.getWatermarkContent(ContentHandlerInput)
public ContentHandlerResult deleteWatermarkContent(ContentHandlerInput input) throws VirtualViewerAPIException
WatermarksInterface
deleteWatermarkContent
in interface WatermarksInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorWatermarksInterface.deleteWatermarkContent(ContentHandlerInput)
public ContentHandlerResult getNotesContent(ContentHandlerInput input) throws VirtualViewerAPIException
DocumentNotesInterface
getNotesContent
in interface DocumentNotesInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_NOTES_CONTENT | byte[] | Contents of the document notes XML file, or null if no document notes have been saved. |
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorDocumentNotesInterface.getNotesContent(ContentHandlerInput)
public ContentHandlerResult deleteNotesContent(ContentHandlerInput input) throws VirtualViewerAPIException
DocumentNotesInterface
deleteNotesContent
in interface DocumentNotesInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorDocumentNotesInterface.deleteNotesContent(ContentHandlerInput)
public ContentHandlerResult getDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException
VirtualViewerContentHandlerInterface
// This example retrieves the document content from a specific directory in the local filesystem.
public ContentHandlerResult getDocumentContent(ContentHandlerInput input)
throws VirtualViewerAPIException
{
String clientInstanceId = input.getClientInstanceId();
String documentKey = input.getDocumentId();
String fullFilePath = gFilePath + URLDecoder.decode(documentKey);
File file = new File(fullFilePath);
byte[] fileBytes = com.snowbound.common.utils.ClientServerIO.getFileBytes(file);
ContentHandlerResult result = new ContentHandlerResult();
result.put(ContentHandlerResult.KEY_DOCUMENT_CONTENT, fileBytes);
return result;
}
// This example retrieves document content from the local file system and adds the same cover page to every
// requested document by returning them as a compound document.
public ContentHandlerResult getDocumentContent(ContentHandlerInput input)
throws VirtualViewerAPIException
{
String clientInstanceId = input.getClientInstanceId();
String documentKey = input.getDocumentId();
List<Object> contentElements = new List<Object>();
//Adding the cover page first will make it the first page(s) of the document
InputStream coverPage = getCoverPageStream();
contentElements.put(coverPage);
//Add the file content from the local system next
String fullFilePath = gFilePath + URLDecoder.decode(documentKey);
File file = new File(fullFilePath);
byte[] fileBytes = com.snowbound.common.utils.ClientServerIO.getFileBytes(file);
contentElements.put(fileBytes);
ContentHandlerResult result = new ContentHandlerResult();
result.put(ContentHandlerResult.KEY_DOCUMENT_CONTENT_ELEMENTS, contentElements);
return result;
}
// This example assumes the existence of a function that returns a single page of the document. To fit the best
// use case of sparse documents, this function should be relatively expensive, so calling it for each page of
// the document is not ideal.
public ContentHandlerResult getDocumentContent(ContentHandlerInput input)
throws VirtualViewerAPIException
{
String clientInstanceId = input.getClientInstanceId();
String documentKey = input.getDocumentId();
Integer requestedPageIndex = input.get(ContentHandlerInput.KEY_SPARSE_PAGE_INDEX);
List<byte[]> sparseElements = new List<byte[]>();
int documentPageCount = getDocumentPageCount(documentKey);
int startPageIndex = 0;
int returnPageCount = documentPageCount;
//If KEY_SPARSE_PAGE_INDEX is null, all pages should be returned. If it is set then we will return the requested
//page and the two next pages.
if(requestedPageIndex != null) {
startPageIndex = requestedPageIndex;
returnPageCount = 3;
//Make sure not to request more pages than the document has
if(startPageIndex + returnPageCount > documentPageCount) {
returnPageCount = documentPageCount - startPageIndex;
}
}
for(int index = startPageIndex; index < startPageIndex + returnPageCount; index++) {
byte[] documentPage = getSingleDocumentPage(documentKey, index);
sparseElements.put(documentPage);
}
ContentHandlerResult result = new ContentHandlerResult();
result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_ELEMENTs, sparseElements);
result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_PAGE_INDEX, startPageIndex);
result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_RETURN_PAGE_COUNT, returnPageCount);
// For this example we are assuming each document is exactly 10 pages long.
// In actual code the real length should be returned.
result.put(ContentHandlerResult.KEY_DOCUMENT_SPARSE_TOTAL_PAGE_COUNT, 10);
return result;
}
ExternalReference
objects.
Note: This feature is currently only supported when running the VirtualViewer server on Windows.getDocumentContent
in interface VirtualViewerContentHandlerInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
KEY_SPARSE_PAGE_INDEX | Integer | The specific page index being requested. This parameter is used only for sparse documents. If
this parameter is null, the entire document should be returned, even for sparse documents. (For
sparse documents this should be in the form of a complete KEY_DOCUMENT_SPARSE_ELEMENTS list).
Can be retrieved with
|
KEY_SPARSE_PAGE_COUNT | int | Suggested number of pages to return for a sparse document. This does not have to be respected.
Can be retrieved with
|
Key | Type | Description | |
---|---|---|---|
KEY_DOCUMENT_DISPLAY_NAME | String | The name VirtualViewer should display for this document. If omitted VirtualViewer will display the document key instead. | |
KEY_DOCUMENT_CONTENT | byte[] | A byte array of the document content. Only one document content return parameter should be set. | |
KEY_DOCUMENT_INPUT_STREAM | java.io.InputStream | An input stream of the document content. Only one document content return parameter should be set. | |
KEY_DOCUMENT_FILE | java.io.File | A File object referencing the document content file. Using KEY_DOCUMENT_CONTENT or KEY_INPUT_STREAM is recommended for efficiency. Only one document content return parameter should be set. | |
KEY_DOCUMENT_CONTENT_ELEMENTS | java.util.List | A list of content elements - byte arrays, input streams or File objects. They do not have to be in the same form, nor do the original files need to be the same image or document format (a content element list consisting of a JPEG byte array and a PDF input stream is acceptable). VirtualViewer will treat all of the content elements as if they formed one contiguous document. If a list containing only one content element is returned, it will behave exactly as the single-content element cases above. Only one document content return parameter should be set. | |
KEY_DOCUMENT_SPARSE_ELEMENTS | java.util.List | A parameter required for sparse documents. A list of single-page content elements - byte arrays or input streams only. File objects are not supported. If one of the content elements is of a format that supports multiple pages, such as PDF, it must be one page. Any pages beyond the first will be ignored by VirtualViewer. Only one document content return parameter should be set. | |
KEY_DOCUMENT_SPARSE_PAGE_INDEX | java.util.List | A parameter required for sparse documents. The zero-based page index at which the collection of returned pages start. For example, if page index 5 is requested and you are returning pages 5-8, this should equal 5. | |
KEY_DOCUMENT_SPARSE_RETURN_PAGE_COUNT | java.util.List | A parameter required for sparse documents. The number of pages you are returning with this method. For example, if page index 5 is requested and you are returning pages 5-8, this should return 4. | |
KEY_DOCUMENT_SPARSE_TOTAL_PAGE_COUNT | java.util.List | A parameter required for sparse documents. The total number of pages in the sparse document. This should be the same in each request for a given document. For example, when a 300-page-long document is requested, this should be 300 - regardless of how many pages are being returned for the request. | |
KEY_EXTERNAL_REFERENCE_CONTENT_ELEMENTS | java.util.List<ExternalReference > |
A list of external references for CAD/DWG files. |
VirtualViewerAPIException
- if content handler throws exceptionVirtualViewerContentHandlerInterface.getDocumentContent(ContentHandlerInput)
public ContentHandlerResult getDocumentContentByFile(ContentHandlerInput input) throws VirtualViewerAPIException
VirtualViewerAPIException
public ContentHandlerResult deleteAnnotation(ContentHandlerInput input) throws VirtualViewerAPIException
AnnotationsInterface
deleteAnnotation
in interface AnnotationsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_ANNOTATION_ID | java.lang.String | The key for the annotation layer to be deleted. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorAnnotationsInterface.deleteAnnotation(ContentHandlerInput)
public ContentHandlerResult getAvailableDocumentIds(ContentHandlerInput input) throws VirtualViewerAPIException
AvailableDocumentsInterface
Example:
// This example retrieves all of the filenames in a specific directory as available documents
public ContentHandlerResult getAvailableDocumentIds(ContentHandlerInput input)
throws VirtualViewerAPIException
{
String clientInstanceId = input.getClientInstanceId();
File imgDirectory = new File(gFilePath);
String[] myArray = imgDirectory.list(this);
ContentHandlerResult result = new ContentHandlerResult();
result.put(ContentHandlerResult.KEY_AVAILABLE_DOCUMENT_IDS, myArray);
return result;
}
getAvailableDocumentIds
in interface AvailableDocumentsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_AVAILABLE_DOCUMENT_IDS | java.lang.String[] | Array of keys for available documents |
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorAvailableDocumentsInterface.getAvailableDocumentIds(ContentHandlerInput)
public ContentHandlerResult sendDocumentContent(ContentHandlerInput input) throws VirtualViewerAPIException
SendDocumentInterface
sendDocumentContent
in interface SendDocumentInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_CONTENT | byte[] | The document file content. Can be retrieved with . |
KEY_DOCUMENT_FORMAT | int |
An integer code representing the document format. Can be retrieved along with a format information object with the following code:
|
KEY_MERGE_ANNOTATIONS | boolean | Whether annotations have been merged into the document to be sent. Can be retrieved with . |
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorSendDocumentInterface.sendDocumentContent(ContentHandlerInput)
public ContentHandlerResult eventNotification(ContentHandlerInput input) throws VirtualViewerAPIException
EventSubscriberInterface
eventNotification
in interface EventSubscriberInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_EVENT | java.lang.Object | The type of event, as a constant property of ContentHandlerInput (e.g. ContentHandlerInput.VALUE_EVENT_SAVE_DOCUMENT). |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
VirtualViewerAPIException
- can throw VirtualViewer exception to raise and log an errorEventSubscriberInterface.eventNotification(com.snowbound.contenthandler.ContentHandlerInput)
public static void setSupportsTiffTagAnnotations(boolean pValue)
public ContentHandlerResult getAllAnnotationsForDocument(ContentHandlerInput input) throws VirtualViewerAPIException
AllAnnotationsInterface
getAllAnnotationsForDocument
in interface AllAnnotationsInterface
input
- ContentHandlerInput containing the following values:
Key | Type | Description |
---|---|---|
KEY_DOCUMENT_ID | java.lang.String | The key representing the document. Can be retrieved with . |
KEY_CLIENT_INSTANCE_ID | java.lang.String | Custom configurable value used to pass data from client to content handler. If not set then will be set to
the session ID. Can be retrieved with
|
KEY_HTTP_SERVLET_REQUEST | javax.servlet.http.HttpServletRequest | Request that called this method. Can be retrieved with
|
Key | Type | Description |
---|---|---|
KEY_ALL_ANNOTATIONS_HASH | java.util.Map | Map of string annotation layer keys to their AnnotationLayer objects. |
VirtualViewerAPIException
- if content handler throws exceptionAnnotationsInterface.getAnnotationContent(com.snowbound.contenthandler.ContentHandlerInput)
Copyright © 2019 Snowbound Software Corporation. All rights reserved.