UIWebView displays an RTF file with images and tables

For the project, I need to display the contents of the RTF file on the iPad. After some searching, I found that you can load the RTF file into a UIWebView. However, when I do this, the contents of the file are displayed, but its missing table and image borders. Bold / Italic / Underline text works great.

The code I use to display the file:

NSURL *url = [[NSBundle mainBundle] URLForResource:@"A" withExtension:@".rtf"]; NSLog(@"URL: %@", url); NSURLRequest *req = [NSURLRequest requestWithURL:url]; [_webView loadRequest:req]; 

RTF file:

https://dl.dropbox.com/u/4966217/A.rtf

How to display images and table borders in my application?

+4
source share
2 answers

If you want to show only rtf file, you can also use QLPreviewController . It supports many file formats for preview.

Here is the documentation link for QLPreviewController : http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/QLPreviewController_Class/Reference/Reference.html

And here is a sample code: http://developer.apple.com/library/ios/#samplecode/DocInteraction/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010052

0
source

Try this code

 NSString *filePath = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"A.rtf"]; NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:fileURL]; [_webView loadRequest:requestObj]; 

to convert it to html

http://dblog.com.au/iphone-development/loading-local-files-into-uiwebview/

http://kiefermat.com/2011/09/30/using-uiwebview-for-displaying-rich-text/

-2
source

Source: https://habr.com/ru/post/1437943/


All Articles