Jaimin
Jaimin

Reputation: 811

search text in pdf in iphone

I am trying to do search functionality in iPhone. I pass the page number and the string to be searched.. but it is not getting the proper output. in contentStream I get nothing. I got this code by googling. I don't know what will be there in contentStream object.

-(BOOL)page:(CGPDFPageRef)inPage containsString:(NSString *)inSearchString {
[self setCurrentData:[NSMutableString string]];
CGPDFContentStreamRef contentStream = CGPDFContentStreamCreateWithPage(inPage);
CGPDFScannerRef scanner = CGPDFScannerCreate(contentStream, table, self);
bool ret = CGPDFScannerScan(scanner);
CGPDFScannerRelease(scanner);
CGPDFContentStreamRelease(contentStream);
return ([[currentData uppercaseString] 
         rangeOfString:[inSearchString uppercaseString]].location != NSNotFound);

}

If there is any other solution then also it is fine.

Upvotes: 0

Views: 1467

Answers (2)

ySgPjx
ySgPjx

Reputation: 10265

Check out this question and its answers for more information: PDF search on the iPhone

Upvotes: 0

GameLoading
GameLoading

Reputation: 6708

YOU SHOULD IMPLEMENT THE COMPLETE CODE

http://www.random-ideas.net/posts/42%22

check out the above link a complete code to do so.

profile for Fasttracks at Stack Overflow, Q&A for professional and enthusiast programmers

Upvotes: 2

Related Questions