hello everyone. I am trying to display the contents of a rtf file in uiwebview. I do this by taking the contents of rtf into nsmutablestring and loading it into uiwebview.
The problem is along with the content of rtf, the rtf tags and format is also passed in the nsmutablestring. so i the entire content is displayed along with the rtf format in uiwebview.
How do i strip the rtf format and tags out of nsmutable string????? plz help me. i have searched a lot on web, with no satisfactory result.
The code is as follows :
UIWebView *webView = [[UIWebView alloc]init];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Home" ofType:@"rtf"];
NSMutableString *rtfString = [[NSMutableString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
NSMutableString *htmlString = [NSMutableString stringWithFormat:@"<font face=\"verdana\" size=\"2\" color=\"green\">%@</font>",rtfString];
[webView loadHTMLString:htmlString baseURL:nil];
This is the output of the rtf file, which is displayed in uiwebview
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf290
{\fonttbl\f0\fnil\fcharset0 LucidaGrande;}
{\colortbl;\red255\green255\blue255;}
\deftab560
\pard\tx560\pardeftab560\ql\qnatural\pardirnatural
\f0\fs22 \cf0 \CocoaLigature0 This is Sample Text. Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.\
\
\
Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.\
\
\
This is sample text.\
\
\
This is sample TExt.}
All the "\" in between the paragraphs are white spaces which signifies paragraph end or paragraph start. This entire result is displayed in uiwebview as it is. so how do i format this. is there any class or framework which i should use???? Plz help me.