Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS read text from MS Word

I am trying to read text from MS Word documents (.doc, .docx, .docs). I have been search from last day, but haven't found any solution for this. Please any one tell me what should i do? I have already tried UIWebview to get text from javascript this isn't working as well.

- (NSString *)textFromWordDocument:(NSString *)path {
    UIWebView *theWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [theWebView loadRequest:request ];
    NSString *document = [theWebView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerText"];
    [theWebView release];
    return document;
}

If some one can tell me what should i do or where to look around, That will be really help full to me thank you

like image 344
Omer Abbas Avatar asked Feb 21 '23 07:02

Omer Abbas


1 Answers

Your loading the UIWebView and then immediately trying to access the dom, its probably not yet ready.

Don't call stringByEvaluatingJavaScriptFromString: until UIWebViewDelegate didFinishLoad: has been called.

like image 80
Gruntcakes Avatar answered Feb 28 '23 06:02

Gruntcakes