Thank you for the reply. Below is my code to initialize WebViewer.
window.myWebViewer = new PDFTron.WebViewer({
type: "html5",
path: path/to/web/viewer,
initialDoc: path/to/xod,
documentId: "bookId",
mobileRedirect: false,
streaming : true,
config: "path/to/config.js",
custom: JSON.stringify({currentPage : page, searchWord : word}),
enableAnnotations: true
}, viewerElement);
$(viewerElement).bind('documentLoaded', function(event) {
//myWebViewer.setCurrentPageNumber(11);
myWebViewer.setLayoutMode("SinglePage");
myWebViewer.setSideWindowVisibility("false");
myWebViewer.setZoomLevel(0.9);
$("#displayModeMenu").hide();
$('#rotateButton').hide();
myWebViewer.setToolMode("Pan");
$('#pageNumberBox').text('disable');
});
Below is my custom config file does. It takes page number and the word, and it highlights all the instances of the word in that page. Below is the function for highlighting
function highlightText(quads) {
var docViewer = readerControl.docViewer;
var am = docViewer.GetAnnotationManager();
var firstChar = quads[0];
var lastChar = quads[quads.length - 1];
var firstx = (firstChar.x1 + firstChar.x2) / 2;
var finalx = (lastChar.x3 + lastChar.x4) / 2;
var y = (firstChar.y1 + firstChar.y4) / 2;
var topLeft = { x: firstx, y: y, pageIndex: currentPage };
var bottomRight = { x: finalx, y: y, pageIndex: currentPage };
var annot = new Annotations.TextHighlightAnnotation();
annot.SetPageNumber(currentPage);
annot.StrokeColor = new Annotations.Color(255, 255, 0);
am.AddAnnotation(annot);
var textHighlightTool = new window.Tools.TextHighlightCreateTool(docViewer);
textHighlightTool.annotation = annot;
textHighlightTool.pageCoordinates[0] = topLeft;
textHighlightTool.select(topLeft, bottomRight);
}
Also, it disables the nextpage and previous buttons once the condition is met. Typically, it should allow only a range of 5 pages from the current page.
Please let me know what can be done in this case.Thank you for your time and help.