findText method

List<MatchedItem> findText(
  1. List<String> searchString, {
  2. int? startPageIndex,
  3. int? endPageIndex,
  4. TextSearchOption? searchOption,
})

Returns the information of the matched texts in a specific page based on the list of string to be searched

startPageIndex and endPageIndex specifies the page range to be selected to find text. for example, startPageIndex is 0 and endPageIndex is 9 is used to find text from first page to 10 page of loaded PDF

for finding text and get matched item from particular page, we can set an index of the page to startPageIndex

search option defines the constants that specify the option for text search

//Load an exisiting PDF document.
PdfDocument document = PdfDocument.fromBase64String(pdfData);
//list of string to be searched.
List<String> searchString = <String>['text1', 'text2'];
//Find text and get matched items.
List<MatchedItem> textLine = PdfTextExtractor(document).findText(searchString);
//Dispose the document.
document.dispose();

Implementation

List<MatchedItem> findText(List<String> searchString,
    {int? startPageIndex,
    int? endPageIndex,
    TextSearchOption? searchOption}) {
  return _findText(searchString, startPageIndex, endPageIndex, searchOption);
}