Content Management and Capture

 View Only

Best Practices : API to export document and annotations in ViewONE Virtual.

By Dhananjay Bhandarkar posted Mon June 28, 2021 04:11 PM

  

IBM® Daeja® ViewONE Virtual introduced JavaScript API to export all supported documents with annotation as PDF. With this API you can export document with annotations loaded in viewer or combine document and annotation by specifying their URL.

This API is available in IBM Daeja ViewONE Virtual from V5.0.7 iFix5.

Syntax :

<viewone object id>.exportDocument(documentURL, annotationURL, callback)

Note : Here <viewone object id> is the Viewer ID you specify for ViewONE object in your html. Consider I have defined it as id=viewONE for this documentation.

documentURL is a full URL string to the document and can be null if you are exporting the current document that is opened in the viewer.

annotationUrl is a full URL string to the annotations and can be null if you are exporting the current document that is opened in the viewer or if no annotations exist for the document.

callback is an object that must have three methods, which can be called by the export process:

onSuccess(downloadLocation): The export process calls this method when the export is successful and passes the download URL string to the exported.

onError(errorMsg): The export process calls this method if the export finished with an error and passes the error message.

onStatusUpdate(message, error, pagesProcessed): The export process calls this method periodically as it checks for the export status. message is the progress status or is empty, error is a Boolean that indicates whether there was an error, pagesProcessed is the number of pages that are exported.


If documentURL is null, annotationUrl is ignored. If you export the current document that is opened in the viewer, the document and any annotations displayed in the viewer are exported.

Sample code snippet.

var callback = {

    onSuccess : function(downloadLocation) {
        console.log("Download Location: "+downloadLocation);
    },

    onError : function(errormsg) {
        console.log("Error: "+errormsg);
    },

    onStatusUpdate : function(message, error, pagesProcessed) {
        console.log("Pages Processed: "+pagesProcessed);
        console.log("Message: "+message);
        console.log("Error: "+error);
    }
};

viewONE.exportDocument("http://localhost:8080/viewone/sampledocs/photo.jpg","http://localhost:8080/viewone/sampledocs/myAnnot.ant",callback);​







0 comments
40 views

Permalink