Pages

Friday, January 6, 2012

DOC file to RTF format in asp.net C#.

DOC file to RTF format in asp.net C#.

Introduction : This article describe how you can convert the DOC file to RTF format in asp.net using c# language .

Code For Doc to RTF: I have created one function to convert DOC file to RTF format in c# . You need to pass just doc file path to it and it save the .RTF format file .
First you need to add reference of Microsoft.Office.Interop.Word.dll dll in project .
Microsoft.Office.Interop.Word.dll

Function For Conversion Doc To RTF :
public void ConvertDocToRTF(string DocPath)
{        
        //Creare object of documnet .
        Document document = new Document();
        try
        {
          //Load doc file from given path
          document.LoadFromFile(DocPath);
         //Save doc file. It will convert to .Rtf format .
          document.SaveToFile("Tesfile.rtf", FileFormat.Rtf);
        }
        catch (Exception) { throw; }
}

Call Function :
ConvertDocToRTF("MyDocFilePath");


Related Other posts

2 comments: