Solved

Opening a word doc from remote location thru http programatically which has image ,tables

Posted on 2004-10-12
6
207 Views
Last Modified: 2010-04-17
Hi,

  i am facing some problem in opening a word doc from remote location thru http programatically which has images ,tables.

The code used for the functionality is as follows:

     
Stream = response.GetResponseStream
        Dim str As StreamWriter
        flePath = "c:\aspo\temp_ject.doc"
       
        Dim s2 As FileStream
        If fs.Exists(flePath) Then
            fs.Delete(flePath)
        End If
        fs = Nothing
 
        Dim bryRead As System.IO.BinaryReader
        bryRead = New System.IO.BinaryReader(stream)
        Dim by(resnet.ContentLength) As Byte
        Dim x As Integer : x = bryRead.Read(by, 0, resnet.ContentLength)
        Dim bryWrite As System.IO.BinaryWriter
        Dim fs2 As System.IO.FileStream
        fs2 = New System.IO.FileStream("c:\aspo\temp_ject.doc", System.IO.FileMode.CreateNew, System.IO.FileAccess.Write)
        bryWrite = New System.IO.BinaryWriter(fs2)
        bryWrite.Write(by, 0, by.Length)
        bryWrite.Close()
        bryRead.Close()
        stream.Close()
        fs2.Close()

Note:
No problem in opening a normal imageless,tableless document using response object GetResponseStream()  and saving it.

Problem is in having images,tables in the binary content of GetResponseStream. The file is getting saved and the file of same bytes, but unable to open in word application.

Is there anyother way to solve this issue.

Thanks in Advance,
jaba



0
Comment
Question by:jaba_net
  • 3
  • 2
6 Comments
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 12285447
Have you tried modifying this code to just read a DOC from disk and write it to another location on disk - i.e. remove the HTTP component from the app. In this way you can eliminate if the problem is in how the data is moved over the HTTP link or if it is in the way you are dealing with the file itself.
0
 

Author Comment

by:jaba_net
ID: 12285576
Hi julian,

 As you said its locally working fine but using http we are facing problem. Ordinary text content coming properly thru http but images giving problem unable to open the document itself


Thanks in advance,
jaba
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 12285682
Ok - I am a bit confused - can you clarify for me

Situation 1

Application opens doc WITH images and tables - data read from C:\aspo\temp_ject.doc and writes to C:\aspo\temp_ject2.doc i.e. no HTTP [Works|Fails]?

Situation 2

Application receives doc by HTTP NO images and tables - data readfrom Response.GetResponseStream and writes to c:\aspo\temp_jet.doc [Works|Fails]?

Situation 3

Application receives doc WITH images and tables data - readResponse.GetResponseStream and writes to c:\aspo\temp_jet.doc [Works|Fails]?

Which work and which fail?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 19

Assisted Solution

by:RanjeetRain
RanjeetRain earned 125 total points
ID: 12286976
Who has written the code on the server-side? Do yo have control over it? If you do, add a content-type header to the Response stream. Something like this should eliminate your problem:


Response.AddHeader "Content-Type", "Application/Octet-stream"

This causes the stream to be treated as a binary stream.
0
 
LVL 54

Accepted Solution

by:
Julian Hansen earned 125 total points
ID: 12287367
How are you accessing the word document - are you issuing a URL to the file? If so then the server should automatically set the ContentType for you.

Can you give us a sample of the URL you are trying to read from.
0
 

Author Comment

by:jaba_net
ID: 12662291
Hi,

Thanks for the tip the problem was with the ContentType.

regards,
jaba
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 88
splitOdd10 challenge 5 109
How to obtain Administrator permission when you are the Administrator 6 80
Help Required 2 34
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question