3
votes

I'm using an UIWebView for viewing .pdf, .txt, .xls, .ppt files. I used webView loadRequest method for viewing these files and its working fine. I need to view files such as .odp, .odt, .ods etc, but its showing only blank page in UIWebView. Is there any effective method for viewing these files using UIWebView or any direct method for doing the same?

2
Have you found the solution for this?IamAnil

2 Answers

0
votes

Have you tried using the UIWebView method load, specifying the MIME type? For example for an .odt file:

webView.load(loadedData as Data, mimeType: "application/vnd.oasis.opendocument.text", textEncodingName: "utf-8", baseURL: NSURL() as URL)

If that does not work, then I'm afraid you'll have to write your own open office document loader...

0
votes

WebODF libs integration with UIWebView: Integrated WebODF libs with UIWebView and it's working fine. Please find the below steps

1) Load index.html file from WebODF libs on UIWebView

2) Inject .odt file On webViewDidFinishLoad using below code snippet

let jsFunction = "createEditor(\"../default.odt\", \"Test\", 375, 667)" webView.stringByEvaluatingJavaScript(from: jsFunction) 3) Successfully load the odt file.

More information : https://github.com/kogmbh/WebODF/issues/945