TextSearch in Java:
Highlights hlts = result.getHighlights();
hlts.begin(doc);
while ( hlts.hasNext() )
{
Page cur_page= doc.getPage(hlts.getCurrentPageNumber());
double[] q = hlts.getCurrentQuads();
int quad_count = q.length/8;
System.out.println("The current highlight is from page: " + hlts.getCurrentPageNumber());
for ( int i = 0; i < quad_count; ++i )
{
//assume each quad is an axis-aligned rectangle
int offset = 8*i;
double x1 = Math.min(Math.min(Math.min(q[offset+0], q[offset+2]), q[offset+4]), q[offset+6]);
double x2 = Math.max(Math.max(Math.max(q[offset+0], q[offset+2]), q[offset+4]), q[offset+6]);
double y1 = Math.min(Math.min(Math.min(q[offset+1], q[offset+3]), q[offset+5]), q[offset+7]);
double y2 = Math.max(Math.max(Math.max(q[offset+1], q[offset+3]), q[offset+5]), q[offset+7]);
System.out.println("Quads: x1:"+x1+", y1:"+y1+", x2:"+x2+", y2:"+y2+"" );
}
hlts.next();
}
Highlight code added in ReaderControl.js:
mySelectText:function(coords){
var topLeft = { x: coords.x1 , y: coords.y1, pageIndex: coords.pageNumber};
var bottomRight = { x: coords.x2, y: coords.y2, pageIndex: coords.pageNumber};
var annot = new Annotations.TextHighlightAnnotation();
annot.SetPageNumber(currentPageNumber);
annot.FillColor = new Annotations.Color(0, 255, 255);
var textHighlightTool = new this.docViewer.ToolModes.TextHighlightCreate(this.docViewer);
textHighlightTool.annotation = annot;
textHighlightTool.pageCoordinates[0] = topLeft;
textHighlightTool.pageCoordinates[1] = bottomRight;
textHighlightTool.select(topLeft, bottomRight);
},
var textSelectTool = new docViewer.ToolModes.TextSelect(docViewer);
textSelectTool.select(topLeft, bottomRight);