Text search
Foxit PDF SDK for iOS provides in-document text search via Core SDK, returning page index, character range, rectangles, and related match data.
UI Extensions built-in search
With the full reader (UI Extensions), users open the search panel from the toolbar for keywords, highlights, and navigation—no extra code required.
Core class
| Class | Description |
|---|---|
FSTextSearch | Text search engine; construct from FSPDFDoc |
Search flag constants
| Constant | Description |
|---|---|
FSTextSearchSearchNormal | Default; case-insensitive |
FSTextSearchSearchMatchCase | Case-sensitive |
FSTextSearchSearchMatchWholeWord | Whole word |
FSTextSearchSearchConsecutive | Consecutive search |
Example: search in a document
objc
#import <FoxitRDK/FSPDFObjC.h>
FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];
FSTextSearch *textSearch = [[FSTextSearch alloc] initWithDocument:doc
cancel:nil
flags:FSTextPageParseTextNormal];
[textSearch setStartPage:0];
[textSearch setEndPage:[doc getPageCount] - 1];
[textSearch setPattern:@"foxit"];
[textSearch setSearchFlags:FSTextSearchSearchMatchCase];
while ([textSearch findNext]) {
int pageIndex = [textSearch getMatchPageIndex];
int startChar = [textSearch getMatchStartCharIndex];
int endChar = [textSearch getMatchEndCharIndex];
FSRectFArray *rects = [textSearch getMatchRects];
NSString *sentence = [textSearch getMatchSentence];
NSLog(@"在第 %d 页找到匹配,字符范围: %d-%d", pageIndex, startChar, endChar);
}Open search in UI Extensions
objc
[extensionsManager showSearchBar:YES];API reference
See the API reference for FSTextSearch.