Hi,
I am working on project where asp.net is front end. While working in project I stopped at one place. I unable to convert doc file into html. So if you know what is process to convert doc file into html plase help me.
Hi,
I am working on project where asp.net is front end. While working in project I stopped at one place. I unable to convert doc file into html. So if you know what is process to convert doc file into html plase help me.
If you want to view file in web browser, just change doc file extension into html. As per my knowledge you have to save word file with .html extension.
I think this will help you.
For converting doc file into html using asp.net we must have MS Word installed on the same server where ASP.NET is running. After this you can make reference to particular ASP.NET project. You can find Word library by following steps:
In Solution window -> you can find your project -> then right-click on it -> now choose "Add Reference"-> click on COM tab -> now get Microsoft Word 11 Object Library ->select it -> now press OK
After this you can use "Word" namespace.Now upload your file in sample webpage.
use following code
Code:protected void B1(object s, EventArgs e) { if (FileUpload1.HasFile) { string FTSI = @"c:\temp\doc\"; string FP = folder_to_save_in + FileUpload1.FileName; FileUpload1.SaveAs(FP); Word.ApplicationClass wordApplication = new Word.ApplicationClass(); object oNO = System.Reflection.Missing.Value; object oFP = FP; Word.Document doc = wordApplication.Documents.Open(ref oFP, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO); string newfilename = folder_to_save_in + FileUpload1.FileName.Replace(".doc", ".html"); object oNF = newfilename; object oFR = Word.WdSaveFormat.wdFormatHTML; object oEN = Microsoft.Office.Core.MsoEncoding.msoEncodingUTF8; object oEN = Word.WdLineEndingType.wdCRLF; wordApplication.ActiveDocument.SaveAs(ref oNF, ref oFR, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO, ref oNO); Label1.Text = "Uploaded file successfully!"; doc.Close(ref oNO, ref oNO, ref oNO); } }
Bookmarks