开发者

iphone and ipad epub reader for xcode

开发者 https://www.devze.com 2023-02-10 08:52 出处:网络
I have done the followings 开发者_开发知识库in objective c and javascript, 1. extract the epub file using unzip library.
 I have done the followings 开发者_开发知识库in objective c and javascript,

    1. extract the epub file using unzip library.
    2. parse the .opf file to get the .xhtml files .
    3. Using navigation tab i have display the contents like plain text .
    4. Each page javascript to display contents in page by page to the html.
    5. i finished the page flip also works fine.

I have to implement the followings,

    1.Apply CSS to the html contents like iBooks

Anybody know how to apply css to displayed contents. I have tried to one weeks till now i did't get the solution.

 Thanks in Advance,

With Regards, Suresh.M


You could try something like this:

    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.
"}"
"}";

    // NSLog(@"w:%f h:%f", webView.bounds.size.width, webView.bounds.size.height);

NSString *insertRule1 = [NSString stringWithFormat:@"addCSSRule('html', 'padding: 0px; height: %fpx; -webkit-column-gap: 0px; -webkit-column-width: %fpx;')", webView.frame.size.height, webView.frame.size.width];
NSString *insertRule2 = [NSString stringWithFormat:@"addCSSRule('p', 'text-align: justify;')"];
NSString *setTextSizeRule = [NSString stringWithFormat:@"addCSSRule('body', '-webkit-text-size-adjust: %d%%;')",fontPercentSize];

I get that code from AePubReader... by Federico Frappi

Cheers!

0

精彩评论

暂无评论...
验证码 换一张
取 消