The text object is an instance accessible from the main mupdfwv.MuPDFWebViewer instance as follows:

const text = mupdf.text;

This assumes you have returned your instance name as mupdf from the initMuPDFWebViewer() promise!

text

The text object has the following methods:

search(config: { keyword: string; caseSensitive?: boolean; useRegex?: boolean; pageRange?: string })

Searches for text.

  • Arguments:
    • config – The configuration object.

Config object:

  • Arguments:
    • keyword(required) Search keyword.
    • caseSensitive(optional) Whether to be case sensitive.
    • useRegex(optional) Whether to use regular expressions.
    • pageRange(optional) Page index range to search (e.g., “1-5, 7, 9-12”, “all”). If not set will search all pages.
  • Returns: Promise<{ results: { words: { prefix: string; keyword: string; suffix: string; redMarked: boolean; rects: mupdfwv.TRect[]; }[]; pageIndex: number; }[]; }.

Example

mupdf.text.search({keyword:"hello"});

// returns e.g.

{
results: {
    words: {
    prefix: string;
    keyword: string;
    suffix: string;
    rects: {
        top: number;
        left: number;
        bottom: number;
        right: number;
    }[];
    }[];
}[];
}