DocuVieware Reference Guide
RegisterOnTextAnnotated
Reference Guides > JavaScript API > Events > RegisterOnTextAnnotated
 RegisterOnTextAnnotated

This function allows you to trigger a function of your own when an selected text annotation has been added (either through the context menu or through the corresponding JavaScript methods).

RegisterOnTextAnnotated: function (docuViewareID, callback)

Parameters

docuViewareID
The identifier for the DocuVieware™ instance.
callback
The function you want to execute on event.
The callback provides an argument having a prototype { userAction , [{ id, pageNo }] }.
- userAction specifies the selected text annotation action that has been taken, it can be "highlight", "strikeout" or "underline".
- resultAnnots is an array of object with the following content:
   - id specifies the annotation unique id that can be retrieved from the server side using the Guid property of the annotation class.
   - pageNo is the page number the annotation has been added on.

Return Value

1 if error.

Example of usage

This JavaScript makes sure the DocuVieware control is properly loaded and initialized and then subscribes to the event on load to display the corresponding selected text annotations result object in the console.

function RegisterOnTextAnnotatedOnDocuViewareAPIReady() {
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
        DocuViewareAPI.RegisterOnTextAnnotated("DocuVieware1", function (annots) { console.log(annots); });
    }
    else {
        setTimeout(function () { RegisterOnTextAnnotatedOnDocuViewareAPIReady() }, 10);
    }
}
document.addEventListener("DOMContentLoaded", function () {
    RegisterOnTextAnnotatedOnDocuViewareAPIReady();
}, false);