473,466 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MS Word to ByteArray

10 New Member
Hi all,

I am using a WebService in ASP.Net 2.0 to retrieve Data in XTHML format. I want to put this data in a Word Document and send this document to the client. Till now, I just used Response.AddHeader and set the type to "Application/MSWord". It was a plain text file, but because of the extension .doc, the user coult opened the document in word. And Word is able to show HTML Documents, so everything worked fine.

But now, I have to put images in that document. So I can't use the HTML File approach anymore. So I have used the Word Interop to create a word document. Afterwards I put the XHTML Resopnse into the word document via the Selection.InsertXML method. Now it is time to send this word document to the client, without saving it to disk. What I need is to convert the word document to a byte array or a memory stream, but I couldn't find out how.

So can you tell me how I can convert a Word Document in memory to a byte array or to a memroyStream?

Thanks for help
Nov 5 '07 #1
2 2021
JamieHowarth0
533 Recognized Expert Contributor
Hi there,

I moved your thread to the .NET Forum as it seemed more appropriate, dealing with ByteArrays in .NET is very different to handling any binary files in ASP.

Can you simply not add the <img> tag for the images you need to include? The user's Word program should parse these images from the Net into the program nicely without any hassle.

Best regards,

medicineworker
Nov 5 '07 #2
koraykazgan
10 New Member
Hi again,

I have to include the images in the word document, because the images are not public in the internet. They have to be included in the word document.

I am getting the xhtml response from a web service. When I create a word document, append the xhtml to the document and save the document, I can create a file stream from the saved document and everything works.

But there will be a lot of users, and I want to avoid the overhead of saving a document, everytime a document is requested. So I just want to get a stream, maybe a memoryStream, from the word document instance in memory.
Nov 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kristina Engdahl | last post by:
Hello, I'm working with dynamic classloading and have encountered a problem when it comes to defining an URL for a file that is available through a bytearray representing a jar-file. The file in...
0
by: Bruce Zigenfous | last post by:
Hello, I am using an ASP that uses a third party active-x control to upload a file to a file server using the ADO Stream Object. It uses the FileSystemObject to create folders and files, which...
0
by: Bruce Zigenfous | last post by:
Hello, Here is the code. followed by an explanation for what I am trying to do. In particular, this line: BinaryStream.Write byteArray 'Need to format <%Response.Buffer=0 %> <!--#include...
4
by: WJ | last post by:
I have documents written in MS/Word (Doc), Ascii Text, and Adobe Acrobat (PDF) formats. They are of type "Image" stored in SQL server. How do I display these documents to the Asp.Net page ? I...
3
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
1
by: gijamie911 | last post by:
int nBytes = 256; byte ByteArray = new byte; int nBytesRead = inputStream.Read(ByteArray, 0 , nBytes); recorderID = ""; for (int i...
11
by: Icemokka | last post by:
Hi, I'm need to upload a big file ( 600Mb+ ) to a BLOB field in MSSQL 2005. My code looks like this : fs = New FileStream(sFilePath, FileMode.Open) Dim ByteArray(fs.Length) As Byte...
5
by: Nitin Mahajan | last post by:
Guys Is there a way in C# to create a word object directly from a memory stream without passing that to hard disk (file stream). I think it doesn't makes sense to create a file just to read it...
4
by: ton | last post by:
Hi, I'm creating an application and I want to give users access to saved Word documents on the server. How can I establish this. I prefer to open specific Word documents directly into word on...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.