Word Document converted to html, not opening from Response object RRS feed

  • Question

  • User1550836914 posted

    I have a requirement to read an existing word document, whether it be old 2003 or 2007 from the web server, but don't have it open up to the users.  I need to be able to somehow read the document, and parse it into html to be displayed to users so users cannot merely just save word documents.

     Any idea on how this can be done?  Any components anyone suggests to use possibly?

    Sunday, February 15, 2009 1:14 PM


  • User-2008897719 posted

    You can convert the document file to html by opening it with MS Word and saving it as html. That way you would do the conversion. Use window.open in the clientside to open up the html file in new window thereby showing only HTML content.

    However there are serious things to be noted before you begin:
    1. You cannot instantiate MS Word COM object just like that in Asp.Net. There are a lot of security/licensing issues. An alternative is to do the same action using a .Net Console application and save the HTML files in a pre defined folder and use them from your Asp.Net code.
    2. The HTML version of Doc generated by doing a "Save As" operation is backward compatible, meaning the user downloading it can open it using MS Word and save as a word doc. If you don't want to allow this, you need to parse the HTML text and remove all un-necessary markup added by Word.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 16, 2009 8:01 AM