MCPcopy Create free account
hub / github.com/LibPDF-js/core / findText

Method findText

src/api/pdf.ts:3129–3144  ·  view source on GitHub ↗

* Search for text across all pages in the document. * * @param query - String or RegExp to search for * @param options - Search options (pages, case sensitivity, whole word) * @returns Array of matches with positions * * @example * ```typescript * // Search across all pages

(query: string | RegExp, options: FindTextOptions = {})

Source from the content-addressed store, hash-verified

3127 * ```
3128 */
3129 findText(query: string | RegExp, options: FindTextOptions = {}): TextMatch[] {
3130 const pages = this.getPages();
3131 const pagesToSearch = options.pages ?? Array.from({ length: pages.length }, (_, i) => i);
3132
3133 const results: TextMatch[] = [];
3134
3135 for (const pageIndex of pagesToSearch) {
3136 if (pageIndex >= 0 && pageIndex < pages.length) {
3137 const matches = pages[pageIndex].findText(query, options);
3138
3139 results.push(...matches);
3140 }
3141 }
3142
3143 return results;
3144 }
3145
3146 // ─────────────────────────────────────────────────────────────────────────────
3147 // Change tracking

Callers 4

mainFunction · 0.45
mainFunction · 0.45

Calls 3

getPagesMethod · 0.95
fromMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected