File Formats Supported by UIWebView

What are all the file formats supported by UIWebView? In my testing, I found that it supports XLS, DOC, PPT, PDF but not XLSX, and DOCX, RTF.

It supports image files like, JPG, PNG, GIF, BMP, not sure about TIFF or

Exactly, what all types are supported is not clear...

The UIWebView documentation also doesn't state it clearly.

Could someone please help?


A Technical note is available on Apple Website about file formats supported by UIWebView:

Since iPhone OS 2.2.1

  • Excel (.xls)
  • Keynote (.key.zip)
  • Numbers (.numbers.zip)
  • Pages (.pages.zip)
  • PDF (.pdf)
  • Powerpoint (.ppt)
  • Word (.doc)

Since iPhone OS 3.0

  • Rich Text Format (.rtf)
  • Rich Text Format Directory (.rtfd.zip)
  • Keynote '09 (.key)
  • Numbers '09 (.numbers)
  • Pages '09 (.pages)

I am seeking a definitive answer on this, too.

While the Tech Note tells us which high-level formats are supported, it doesn't tell us which simple formats, e.g. image types, are supported. I need that information, though, in order to let a web server know which formats it can send me (i.e. via http's "Accept" header).

Update

Uh, actually, here's the docs from Apple on supported image formats by UIWebView: http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/GraphicsandDrawing/GraphicsandDrawing.html#//apple_ref/doc/uid/TP40007072-CH10-SW8


.rtf files are apparently supported but I was unable to get the UIWebView to display them properly. It would format the text correctly (size, colour, font etc) but images just plain didn't render (I tried .gif, .png and .jpg to no avail). chances are if you are going to the trouble of using .rtf, you are probably hoping to display images in the UIWebView, since the main benefit of rtf is that you can embed images into the file. This was tried on an actual iPad 1 (4.3) and on a simulated iPhone (4.3).

The code done to display the rtf in a UIWebView required the rtf to be written to a file with the rtf file extension. It refused to load the file if you use no file extension or an incorrect one so make sure you write it as .rtf.

Here is an Objective C function to take an input string (which should contain the rtf you wish to display) and get the UIWebView to load it into view...

-(void) loadRtf : (UIWebView*) webView : (std::string) rtfFile
{
    // This function will write the rtf to a file in your apps bundle location on the iDevice and use
    // the UIWebView to load it...
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *basePath = ([path count] > 0) ? [path objectAtIndex:0] : nil;
    NSString *fullPath = [basePath stringByAppendingPathComponent:@"rtfData.rtf"];
    std::string fp = [fullPath cStringUsingEncoding:NSASCIIStringEncoding];
    std::ofstream fs;
    fs.open(fp.c_str(), std::ios_base::binary);
    if( !fs.is_open() )
        return;
    fs << rtfFile;
    fs.close(); 
    NSURL *url = [NSURL fileURLWithPath:fullPath];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];  
}