Extracting NSAttributedString from UIWebView

I have a UIWebView that is used to display Word & Pages documents. I am trying to extract the contents as a NSAttributedString using:


NSString *html = [self.webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.outerHTML"];


This works fine for Word documents, but returns an empty string for Pages documents.


Does anybody know how to correct this, or is it a 'feature'.

Pages file format is not publicly documented, so I doubt you'll get much help on this.

It isn't necessary for my app to know the format. The Pages document was added to the UIWebView as a zipped document according to instructions in Apple's documentation. UIWebView displays it OK, just like it does .docx and .doc files. Extracting an attributed string from the web view works ok for .doc and .docx files, so why not for a Pages document.

I suspect they don't you (us) parsing their file format. I have no way of knowing for sure though. You could try filing a bug report.

Their file format doesn't come into it. I am simply sending a message to the webview to ask for the attributed text string displayed by the view. It quite happily returns one for a doc/docx file. I don't want or need to know the Pages file format, that's something they can and do when they display the file. I suspect it is a bug, so will submit a report.

Good luck. I'd be curious to know what they say if they respond to your bug repot.

Extracting NSAttributedString from UIWebView
 
 
Q