searchAndHighlight

searchAndHighlight

ADVANCED / PREMIUM BASIC

Searches for keywords within a Word document and highlights them.

Description
public searchAndHighlight (string $source, string $target, string $search [, array $options])

This method allows the highlighting of plain text in a DOCX document.

Parameters

Source

The path to the source Word document.

target

The path to the Word document resulting after the text highlighting.

search

The string of text that you want to highlight.

options

The possible keys and values are:

Key Type Description
highlightColor string

the color used for the highlighting:

  • black
  • blue
  • cyan
  • green
  • magenta
  • red
  • yellow
  • white
  • darkBlue
  • darkCyan
  • darkGreen
  • darkMagenta
  • darkRed
  • darkYellow
  • darkGray
  • lightGray
  • none

The default value is ‘yellow’.

document bool If true highlights the search string in the body of the document. The default value is true.
endnotes bool If true highlights the search string in the document endnotes. The default value is false.
comments bool If true highlights the search string in the document comments. The default value is false.
headersAndFooters bool If true highlights the search string in headers and footers. The default value is true.
footnotes bool If true highlights the search string in the document footnotes. The default value is false.
Return values

Void.

Code samples

Example #1

The resulting Word document looks like: