Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

view .doc, .docx, .rtf, .ppt file in iphone using Webview

I want to view .doc, .docx, .rtf, .ppt file in iphone.

But I guess something is going wrong at my side and its not working for the above formats but my code is working fine for .txt and .pdf files.

I have the read the document regarding Webview it states it supports viewing of the above document.

below is my snippet for .doc

[webView loadData:requestData MIMEType:@"application/msword" textEncodingName:@"UTF-8" baseURL:nil];

for .ppt I am using MIME type as "application/vnd.ms-powerpoint"

Note: If I am making MIME type as "text/html" for .doc/.rtf then it displays some garbage data So I think there is something missing in MIME type from my side.

Any help is highly appreciated.

Waiting for your reply.

Update:........

It seems there is some issue with NSData for opening these type of file formats. My data is encrypted so I cannot use requestWithURL directly and other thing is I need to pass credentials to get the file and the credentials doesnt work proplerly if I save the credentials using

[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential
                                        forProtectionSpace:protectionSpace];

and then make the request using below

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] ]

Is there any way I can use NSData for the above formats so that I can make async call and pass my credentials and then decrypt the data and show it in WebView.

like image 962
Ekra Avatar asked May 24 '10 11:05

Ekra


1 Answers

Try using a QuickLook Framework which is an amazing feature given by Apple. If you have seen this that when you select ANY FILE on MAC System and click SPACE BAR then you will a quick preview of your file it may be any thing... *.pdf, *.doc, *.docx or any thing... Even if you have not installed those softwares for same files you will get a PREVIEW for those files...

QuickLook framework also gives same functionality... Please go through some of the links for the same..

  • http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html
  • https://github.com/rob-brown/Demos
  • https://github.com/rob-brown/RBFilePreviewer
  • http://robsprogramknowledge.blogspot.com/2011/02/quick-look-for-ios_21.html
  • (Recommended..) http://iosdevelopertips.com/data-file-management/preview-documents-with-qlpreviewcontroller.html
like image 175
DShah Avatar answered Nov 14 '22 02:11

DShah