locked
Displaying documents on a web page RRS feed

  • Question

  • Hi

    I want to be able to display Word documents on a page in our Company Intranet  without opening a new browser window, ie. embedded into the actual page.

    Does anyone know how to go about this as i'm struggling to find a way to do it. I thought about saving the documents as XML files, is this a viable option?

    I'm using VB.NET 2005.

    Any help greatly appreciated!

    Friday, January 12, 2007 12:22 PM

Answers

  • I think this is not the right forum for such questions. [Note: this is xml related forum, you should go to http://forums.asp.net]

    The answer is:

    1. The simplest way: put the word documents under one directory in your website somewhere... e.g lets say your site virtual dir name is "YourSite", and under that "docs" folder which contains your all documents then
    http://<yourdomainurl-YourSite>/docs/YourDocument.doc
    If you access this URL then it will open the word document in Webbrowser (embedded)

    2. Create a webpage which reads the word document file using IO APIs and then write the bytes on response stream, it will show the word document in that webpage.



    Response.ContentType = "application/msword";
    FileStream fs =
    new FileStream(@"<path to your word document>", FileMode.Open, FileAccess.Read);
    byte[] b = new byte[(int)fs.Length];
    fs.Read(b,0, (int)fs.Length);
    fs.Close();
    Response.Clear();
    Response.BinaryWrite(b);
    Response.End();

     

    The above code will write your word file into the browser.

    HTH,

    Friday, January 12, 2007 2:32 PM

All replies

  • I think this is not the right forum for such questions. [Note: this is xml related forum, you should go to http://forums.asp.net]

    The answer is:

    1. The simplest way: put the word documents under one directory in your website somewhere... e.g lets say your site virtual dir name is "YourSite", and under that "docs" folder which contains your all documents then
    http://<yourdomainurl-YourSite>/docs/YourDocument.doc
    If you access this URL then it will open the word document in Webbrowser (embedded)

    2. Create a webpage which reads the word document file using IO APIs and then write the bytes on response stream, it will show the word document in that webpage.



    Response.ContentType = "application/msword";
    FileStream fs =
    new FileStream(@"<path to your word document>", FileMode.Open, FileAccess.Read);
    byte[] b = new byte[(int)fs.Length];
    fs.Read(b,0, (int)fs.Length);
    fs.Close();
    Response.Clear();
    Response.BinaryWrite(b);
    Response.End();

     

    The above code will write your word file into the browser.

    HTH,

    Friday, January 12, 2007 2:32 PM
  • Thankyou very much,

    Thanks for giving solution but I want to show word document in panel or frame on webpage. If you have any idea regarding this so please help me.

     

    Thanking you.

    ASH002

     

    Wednesday, December 5, 2007 2:20 PM