I have a .rtf
file. It contains images with Windows Metafile Format(wmf)
. I want to show this file in iOS
app. I tried showing it using NSAttributedString
and in UIWebView
but images are not shown.
How can I show it on iOS
device ?
EDIT
For NSAttributedString
:
var urlpath = NSBundle.mainBundle().pathForResource("txtFile", ofType: "rtf")
var url:NSURL = NSURL.fileURLWithPath(urlpath!)!
if let attributedText = NSAttributedString(fileURL: url, options: [NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType], documentAttributes: nil, error: nil) {
textView.attributedText = attributedText
}
For UIWebView
:
NSString *path = [[NSBundle mainBundle] pathForResource:@"txtFile" ofType:@"rtf"];
NSURL *url = [NSURL URLWithString:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
EDIT2
I tried converting .rtf
file into .rtfd
file format.
RTFD file creates a bundle with TXT.rtf
and images in files. In TXT.rtf
file, images are given as references which are stored separately in RTFD. Like following :
{{\NeXTGraphic img1.png \width40 \height20}¬}
I converted the file into RTFD but issue comes when file contains .wmf
images. Images with .wmf
file format are not getting converted.