Knowledge Base - Search in whole pdf file (iOS)

This article shows how to search a string in whole pdf file:

With this method you can use a PDFDoc instance to search in whole pdf file and store/manage results.

- (void)customSearch:(PDFDoc *)doc ofString:(NSString *)string

{

    BOOL caseSensitive = NO;

    BOOL wholeWord = NO;

    

    for (int i = 0; i < doc.pageCount; i++) {

        

        // get page

        PDFPage *page = [doc page:i];

        [page objsStart];

        

        // find in page

        PDFFinder *finder = [page find:string :caseSensitive :wholeWord];

        

        // manage each search term contained in this page

        for (int c = 0; c < finder.count; c++) {

            

            // start position

            int firstCharPos = [finder objsIndex:c];

            NSLog(@"page: %i", i);

            NSLog(@"pos: %i", firstCharPos);

            // do custom actions

        }

    }

 

}

Applies To

RadaeePDF SDK for iOS

Details

Created : 2017-03-22 10:56:56, Last Modified : 2017-03-22 10:56:56