2015-09-07 110 views
2

我有一個.rtf文件。它包含圖像Windows Metafile Format(wmf)。我想在iOS應用程序中顯示此文件。我試圖用NSAttributedStringUIWebView顯示它,但圖像不顯示。 如何在iOS設備上顯示它?如何在ios中顯示包含wmf圖像的rtf文件

EDIT

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 
} 

對於UIWebView

NSString *path = [[NSBundle mainBundle] pathForResource:@"txtFile" ofType:@"rtf"]; 
NSURL *url = [NSURL URLWithString:path]; 
[self.webView loadRequest:[NSURLRequest requestWithURL:url]]; 

EDIT2

我試圖將.rtf文件轉換爲.rtfd文件格式。

RTFD文件創建一個包含TXT.rtf和文件中的圖像的包。在TXT.rtf文件中,圖像是作爲參考給出的,它們分別存儲在RTFD中。就像下面:

{{\NeXTGraphic img1.png \width40 \height20}¬} 

我轉換的文件到RTFD但是當文件包含.wmf圖像的問題來了。帶有.wmf文件格式的圖像未被轉換。

回答

0

儘量轉換成rtfd INSEAD的rtf

Rich Text Format Directory,也被稱爲RTFD(由於其擴展.rtfd),或RTF格式帶附件

var urlpath = NSBundle.mainBundle().pathForResource("txtFile", ofType: "rtfd") 
var url:NSURL = NSURL.fileURLWithPath(urlpath!)! 
if let attributedText = NSAttributedString(fileURL: url, options: [NSDocumentTypeDocumentAttribute:NSRTFDTextDocumentType], documentAttributes: nil, error: nil) { 
    textView.attributedText = attributedText 
} 
+0

是的,我想這一點。但不工作。 –

相關問題