I would like to convert my .ASPX pages in a source folder to word documents (.DOCX) on the destination folder using ASPOSE.WORDS. Can this be done?
If this is not possible, I would like to convert the rendered .ASPX page from my local website to DOCX file. Please let me know if this can be achieved using ASPOSE.WORDS?
// Get HTML of the page<o:p></o:p>
System.IO.StringWriter oStringWriter = new StringWriter();<o:p></o:p>
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);<o:p></o:p>
StringReader reader = new StringReader(oStringWriter.ToString());<o:p></o:p>
MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd()));<o:p></o:p>
Document doc = new Document(stream);<o:p></o:p>
doc.Save(Response, “ASPX to word.docx”, ContentDisposition.Inline, null);<o:p></o:p>
Thank you very much for your help and quick response. There are compilation errors for the Save method, I have attached the sample code project for your reference. I have downloaded the DLL version of Aspose.Words.dll and using the DLL from net3.5_ClientProfile directory. I have also tried the other DLL that we have from net3.5_ClientProfile_AuthenticodeSigned, it does not work in either cases. Could you please let me know what I was doing wrong with the attached code.
I tried with the Aspose.Words.dll 2.0 dll with VS 2005, it worked but the output was not what I have on my Default.aspx page. It just adds the message “System.Web.UI.HtmlTextWriter” to the document, please take a look at the attached output document.
string newContent = content.Replace("Option ", "Option Replace").Replace("Check Box 2", "Check Box2");
// write the new html to the page
//System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(stringWriter);
StringReader reader = new StringReader(newContent);
MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd()));
Document doc = new Document(stream);