TextApi.search()
Every match, as
SearchMatch[]. Needs the extract feature.methodTextsince 1.0.0
Signature
search(query: string, options?: SearchOptions): Promise<SearchMatch[]>
Parameters
| Parameter | Type | Description |
|---|---|---|
| query | string | The text to find. Must not be empty. |
| options? | SearchOptions | matchCase and matchWholeWord (both default to false), pages (zero-based; restrict the search) and limit (stop after N matches). |
Returns
Promise<SearchMatch[]> Each { pageIndex, text, rects }.
Throws
INVALID_ARGUMENT— an empty query, or an index inpagesout of range.PAGE_ERROR— a page or its text could not be loaded.DOCUMENT_CLOSED— the document has been closed.FEATURE_NOT_LICENSED— the license lacksextract.
Example
TypeScript
const onCover = await doc.text.search('Total', { pages: [0], matchWholeWord: true });