Knowledgebase

Back to Articles List

How do I highlight search results in PDF-XChange Viewer?

Question:

How do I highlight search results in PDF-XChange Viewer?

Answer:

The JavaScript Console must be used for this purpose:

1. Press Ctrl+J to open the JavaScript Console:

2. Copy and paste the following code into the JavaScript Console:

  function DoHighlight(word)

{
    var nTotal = 0;
 for (var p = 0; p < this.numPages; p++)
 {
  var cnt = this.getPageNumWords(p);
  for (var w = 0; w < cnt; w++)
  {
   var s = this.getPageNthWord(p, w);
   if (s == word)
   {
    this.addAnnot({
     page: p,
     type: "Highlight",
     quads: this.getPageNthWordQuads(p, w),
    });
    nTotal++;
   }
  }
 }
 return nTotal;
}

var t = DoHighlight("PDF");
console.println(t + " words were highlighted");

3. Replace the word "PDF" in the line var t = DoHighlight("PDF"); with the word that you want to highlight in the document. Please note that returned results are case-sensitive. (If the required search terms are present in mulitple formats in the document then it is necessary to perform multiple searches in order to highlight them all).

4. Click the Run button on the JavaScript Console:

All instances of the specified word will then be highlighted. The color used for the highlights is the current color of the Highlight Text Tool. This color can be changed as follows:

1. Click View in the Menu Toolbar, then hover over Toolbars and click Comment and Markup toolbar:

Shortcuts to all tools will then be displayed in the main window of the user interface.

2. Right-click the Highlight Text Tool and then click Show Comments Styles Palette:

The Comments Styles Palette will open:

3. Use the Fill Color dropdown menu to select a different color for the Highlight Text Tool:

Please note that PDF-XChange Editor has now superseded PDF-XChange Viewer, which has been discontinued. Search results are highlighted by default in PDF-XChange Editor. It can be downloaded at our products page, which is located here.

Was this article helpful?
Yes No Somewhat