tags:

views:

151

answers:

1

I have loaded a PDF into UIWebView. Now i want to search for strings in that pdf. So I used a string which contains JS steps(used to highlight that specific string) and evaluated it with the webView object like this. But no result was obtained .It was as if nothing had been done. Dont the JS evaluation work on a pdf loaded into a webView? Is there anyother way to search for a string in a PDF loaded into webView?

A: 

Even if you could evaluate JS against a webview that is currently displaying a pdf, the pdf render has no exposed or documented APIs. If you have code that works on HTML then it is not working because the PDF is not exposing an HTML like dom. If you have code that works in the acrobat plugin on a desktop then it won't work because the phone uses a derivative of Apple's Webkit PDF plugin which does not export the same API as Acrobat (as far as I know it exports no API, and if it does it is undocumented). In any event, regardless of why you think your code should work, it won't.

If you want to find a string in a pdf you are going to need to write code to parse the PDF and find that string, and even then you will not be able to highlight the specific string in the webview based renderer.

If you want this sort of functionality you should should use Quartz to directly render your PDFs onto views. Apple provides documentation for how to do that.

Louis Gerbarg
mainly to Louis Gerbarg and others,I did go through the documentation and all u said. I have some doubts. Please answer them. 1.Is there anyother way to load a pdf other than load it to webView? 2.I am loading the pdf into the webView and then i am parsing that pdf. It doesnt have any connection with each other. Then how will i able to find a string even if i do it in parsing? 3.Is there a way to load the parsed pdf into the webView? Then after doing the seach at the time of parsing i can load it into webView.
wolverine