NSString *varMySheet = @"var mySheet = document.styleSheets[0];";
NSString *addCSSRule = @"function addCSSRule(selector, newRule) {"
"if (mySheet.addRule) {"
"mySheet.addRule(selector, newRule);" // For Internet Explorer
"} else {"
"ruleIndex = mySheet.cssRules.length;"
"mySheet.insertRule(selector + '{' + newRule + ';}', ruleIndex);" // For Firefox, Chrome, etc.
"}"
"}";
NSString *insertRule1 = [NSString stringWithFormat:@"addCSSRule('html', 'padding: 0px; height: %fpx; -webkit-column-gap: 0px; -webkit-column- %fpx;')", self.webView.frame.size.height, self.webView.frame.size.width];
NSString *insertRule2 = [NSString stringWithFormat:@"addCSSRule('p', 'text-align: justify;')"];
NSString *setTextSizeRule = [NSString stringWithFormat:@"addCSSRule('body', '-webkit-text-size-adjust: %d%%;')", currentFind];
NSString *setHighlightColorRule = [NSString stringWithFormat:@"addCSSRule('highlight', 'background-color: yellow;')"];
[self.webView stringByEvaluatingJavaScriptFromString:varMySheet];
[self.webView stringByEvaluatingJavaScriptFromString:addCSSRule];
[self.webView stringByEvaluatingJavaScriptFromString:insertRule1];
[self.webView stringByEvaluatingJavaScriptFromString:insertRule2];
[self.webView stringByEvaluatingJavaScriptFromString:setTextSizeRule];
[self.webView stringByEvaluatingJavaScriptFromString:setHighlightColorRule];