Set the target pages that you want to search in

By default, the search plugin will look for matches in all pages of the document. But if you have a reason to search in particular pages, then use the `setTargetPages` function.
It allows you to to filter the destination pages that you want to search in.
const searchPluginInstance = searchPlugin();
const { setTargetPages } = searchPluginInstance;
The function has the following signature:
setTargetPages((targetPage: SearchTargetPage) => boolean): void;
The `SearchTargetPage` type has two properties:
PropertyTypeDescriptionFrom
`numPages``number`The total number of pages2.7.2
`pageIndex``number`The index of page2.7.2
Here is a few examples of using the `setTargetPages` function:
// Only search in even pages
setTargetPages((targetPage) => targetPage.pageIndex % 2 === 0);
// Only search in the page 4
setTargetPages((targetPage) => targetPage.pageIndex === 3);
The example below only search for a given keyword in even pages:

See also