Read RTF in asp.net (Persist entered format)
Posted on 2010-01-03
Good Day! Happy 2010!
I have a doubt that disturbing our team lately regarding the output in RTF format.
Our client need to load RTF file into their existing asp.net site. Our side have researched and noticed a lot of pointer in internet lead us to use editor to display it. But, we can't find any simple editor that solve the mentioned. Most of them giving the solution to prompt the user download the generated RTF(.rtf) file and this is close to client needed, but it should display in site instead of prompt download.
Is that any technique to display RTF formatted text ONLY in asp.net?
Any link or reference also highly acceptable.
I've come across a simple solution to read the RTF file, but i can't able to persist the entered original formatted input such as "Table","Bold", "Underline",..etc to display out in site nicely. Here is the code:
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:Button ID="btnRead" runat="server" Text="Read Word Document" OnClick="btnRead_Click" /><br />
<asp:TextBox ID="TextBox1" runat="server" Height="373px" TextMode="MultiLine" Width="500px"></asp:TextBox>
protected void btnRead_Click(object sender, EventArgs e)
ApplicationClass wordApp = new ApplicationClass();
// Input box is used to get the path of the file which has to be
// uploaded into textbox.
string filePath = FileUpload1.PostedFile.FileName;
object file = filePath;
object nullobj = System.Reflection.Missing.Value;
// here on Document.Open there should be 9 arg.
Document doc = wordApp.Documents.Open(ref file,
Document doc1 = wordApp.ActiveDocument;
string m_Content = doc1.Content.Text;
TextBox1.Text = m_Content;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
Note: C# or vb.net solution is acceptable in this assistance. Any insight to lead us to the solution is highly appreciated.