WebViewer({
path: ‘/Scripts/webviewer/lib’,
initialDoc: path,
}, viewerElement).then(instance => {
var annotManager = instance.docViewer.getAnnotationManager();
//var doc = documentViewer.getDocument();
const { annotationManager, documentViewer, Annotations } = instance.Core;
const searchListener = (searchPattern, options, results) => {
debugger;
// add redaction annotation for each search result
const newAnnotations = results.map(result => {
const annotation = new Annotations.RedactionAnnotation();
annotation.PageNumber = result.pageNum;
annotation.Quads = result.quads.map(quad => quad.getPoints());
annotation.StrokeColor = new Annotations.Color(136, 39, 31);
//annotation.searchPattern = searchPattern;
//annotation.searchOptions = options
//annotation.regex = '^\w{3}\.\w{2}$'
return annotation;
});
annotationManager.addAnnotations(newAnnotations);
annotationManager.drawAnnotationsFromList(newAnnotations);
};
documentViewer.addEventListener('documentLoaded', () => {
const searchPattern = 'search text';
// searchPattern can be something like "search*m" with "wildcard" option set to true
// searchPattern can be something like "search1|search2" with "regex" option set to true
// options default values are false
const searchOptions = {
//caseSensitive: true, // match case
// wholeWord: true, // match whole words only
//wildcard: true, // allow using '*' as a wildcard value
//regex: true, // string is treated as a regular expression
//searchUp: false, // search from the end of the document upwards
//ambientString: false, // return ambient string as part of the result
};
instance.UI.addSearchListener(searchListener);
// start search after document loads
instance.UI.searchTextFull(searchPattern, searchOptions);
});
});
I have used below code for searching with Regex. but it is not working. I have also checked with wildcard as well. It is not working in WebViewer