How can I annotate or redact search results within PrizmDoc?

Question

How can I annotate or redact search results within PrizmDoc? What annotation or redaction types are supported? How can I change the properties of the created marks?

Answer

You can annotate or redact search results using the addMarkFromSearchResult() function from ViewerControl. This function creates a new mark of a specific type and adds it to the location where the specified search result is.

The addMarkFromSearchResult() supports mark types: TextSelectionRedaction, HighlightAnnotation, StrikethroughAnnotation and TextHyperlinkAnnotation.

The addMarkFromSearchResult() function takes two arguments: searchResult and markType. The searchResult is the search result that you want to annotate/redact and markType is the type of mark that will be created.

To perform a search and redact the search results, use the following example:

var requestObject = PCCViewer.search('Con');
 var marks = [];
 var mark;
 requestObject.on(PCCViewer.EventType.SearchCompleted, function (event) {
     var searchResults = event.completedSearchResults;
     for (var i = 0; i < searchResults.length; i++) {
         mark = viewer.viewerControl.addMarkFromSearchResult(searchResults[i], PCCViewer.Mark.Type.TextSelectionRedaction);
         marks.push(mark);
     }
 });

To create a different annotation type from a search result you would change the second argument to the different type. For example, if you wanted a textHyperLinkAnnotation you could do the following:

mark = viewer.viewerControl.addMarkFromSearchResult(result, PCCViewer.Mark.Type.TextHyperlinkAnnotation);

Changing the properties of the mark is fairly straightforward. To set the fill color and the URL string in the TextHyperlinkAnnotation, you would add this after creating the mark:

mark.setHref("https://www.accusoft.com");
mark.setFillColor("#FF0000");

More information on mark types and their properties can be found in our documentation here.