Read word document - Stream


#1

From the demos provided, I see where you allow for a image file to be read in from a memory stream. How do I do this for my base word doc (vb .net)?

Please provide a snippet of code.

Thanks!


#2

Hi,

Thank you for your interest in Aspose.Word.

Do you mean the ProductCatalog demo and use of the merge handler? If so, just set MergeImageFieldEventArgs.ImageStream to a stream object:


Private Sub HandleMergeImage(ByVal sender As Object, ByVal e As MergeImageFieldEventArgs)


If e.FieldName = “PictureFileName” Then



'…


e.ImageStream = imageStream

End If


End Sub


If you mean something else, please elaborate your question.

#3

Thanks for your quick response.
Actually, I just wanted to read in my base word document from a filestream...
Which after reading through the doc files I was able to do so without any issues:

 



Dim FS As New FileStream(strFilePath, FileMode.Open, FileAccess.Read)
Dim doc As Aspose.Word.Document = word.Open(FS)



That seems to be working just fine and I've been able to successfully pull the data from my db create a word document and then a pdf.

However, I am having problems figuring out how to handle the presentation of the word document. I need to display the contents of the DOC or PDF to the clients after the program has completed its routines. I know that this would be pretty easy if I was in a web environment but unfortunately that's not an option for me.

I would suppose that your app doesn't handle the presentation but only the conversion and creation bit. Is this correct?

My first thought was to use:

System.Diagnostics.Process.Start("...document string...")

This works just fine. However, in order to use this statement I have to actually save the file and can't leave it in memory. Any thoughts on how I can get around this? Basically I want to prevent file locks by using the filestream and then have the filestream passed into a word document without having to save the name. Saving the name would be a mess in the large user environment that I would be operating under.

Thanks for your quick response.

Cheers,





#4

You are right, Aspose.Word has no visual functionality at the moment. Also, MS Word cannot load a document from memory, so using Process.Start as you have mentioned seems to be the only applicable way.


#5

Understandable.
I could see why you wouldn’t get into the presentation bit.
Anythought on how I can still keep this as a memory stream? I really don’t want to save the file…

Thanks!


#6

Gave this some more thought and actually read your first comment.
As this is not possible, I am going to playaround with some of the default options in .Net to create unique filenames.

In case someone else is reading this thread, I ended up using something similar to:


Dim tempfilepathname As String = System.IO.Path.GetTempFileName() Dim path = System.IO.Path.GetDirectoryName(tempfilepathname) Dim filename = System.IO.Path.GetFileNameWithoutExtension(tempfilepathname) Dim filepath = path + filename doc.Save(filepath + “.doc”)

I added on the “.doc” as a literal so that I can reuse the same filename for creating a pdf.





#7

I noticed that you have a beta version of a Aspose.Word.Viewer. Will this new feature allow me to output the rendered document via a stream (Without Having to Save the File)?
Thanks!!

Kind Regards.


#8

Yes, using GetPage and GetPages properties of DocumentRenderer object you can acquire document pages rendered into bitmaps and send them over a stream.


#9

Excellent!
I am planning on purchasing your componet by the end of this month – If I purchase the Enterprise Edition will this functionality be included?
I believe that I saw this in another post but just wanted to confirm.

Thank you for your quick responses!!

Kind Regards.


#10

Yes, Aspose.Word.Viewer is included in Enterprise Edition pack. Please mind that now it is still in beta stage - the release is planned for March-April 2006.