Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 11-05-2009, 04:51 AM   #8 (permalink)
wolverine
Registered Member
 
Join Date: Jun 2009
Posts: 181
Smile How to do a search feature in PDF loaded in UIWebView?Plz help me

Quote:
Originally Posted by smasher View Post
Ancient thread bump, for the benefit of googlers. May be the same problem as this thread:

http://www.iphonedevsdk.com/forum/ip...w-problem.html
I have a pdf loaded onto a UIWebView. I want to do search of a string in that PDF. So I used these steps
Code:
	NSString* addressText =[NSString stringWithFormat:searchBar.text];
	NSString *javaSript=[NSString stringWithFormat:
						 @"var highlightStartTag = \"<font style='color:blue; background-color:yellow;'>\";"
						 " var highlightEndTag = \"</font>\";"
						 " var bodyText = document.body.innerHTML;"
						 " var searchTerm=%@;"
						 " var newText = \"\";"
						 " var i = -1;"
						 " var lcSearchTerm = searchTerm.toLowerCase();"
						 " var lcBodyText = bodyText.toLowerCase();"
 						 " while (bodyText.length > 0){"
						 " i = lcBodyText.indexOf(lcSearchTerm, i+1);"
						 " if (i < 0){"
						 " newText += bodyText;"
						 " bodyText = "";}"
						 " else{"
						 " if (bodyText.lastIndexOf(\">\", i) >= bodyText.lastIndexOf(\"<\", i)){"
						 "if (lcBodyText.lastIndexOf(\"/script>\", i) >= lcBodyText.lastIndexOf(\"<script\", i)){"
						 " newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;"
						 " bodyText = bodyText.substr(i + searchTerm.length);"
						 " lcBodyText = bodyText.toLowerCase();"
						 " i = -1;"
						 " }"
						 " }"
						 " }"
						 " }"
						 " bodyText = newText;"
						 " document.body.innerHTML = bodyText;",addressText];
	[webView stringByEvaluatingJavaScriptFromString:javaSript];
But it seems to have no effect. Dont this work on a pdf loaded onto a webView. I have been doing this thing for about 3 days. Plz give me some idea.
wolverine is offline   Reply With Quote
 

» Advertisements
» Online Users: 291
20 members and 271 guests
ADY, apatsufas, BdR, Diegan, djohnson, Duncan C, F_Bryant, glenn_sayers, Guthook, Herbie, ilmman, Joseph Nardone, Music Man, Profile, rodgo, TheWebWizz, VikMyr, vogueestylee, yomo710, ziocleto
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,876
Threads: 89,225
Posts: 380,708
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jorge599
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:00 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.