Free Support Forum - aspose.com

Help Needed for accessing Aspose Word from a memory stream

In my application all the documents will be stored in the Sharepoint server. We can access the these documents only through a Web Service. The web service returns the document content as a byte array. My requirement is to access a word document from the Sharepoint server through the Web service and display it in a aspx page.

I used the following code.

Stream ms = new MemoryStream();
ms.Write(binaryData, 0, binaryData.Length);

Aspose.Words.Document doc = new Aspose.Words.Document(ms);
MemoryStream msStream = new MemoryStream();
doc.Save(msStream, SaveFormat.Html);
msStream.Position = 0;
StreamReader reader = new StreamReader(msStream);
ReadText(reader); //This will read the content to a literal control in the aspx page.

But I am getting the error "Unknown file format." Then I tried the following code and this worked properly.

Stream stream = File.OpenRead(sourcePath);
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
MemoryStream msStream = new MemoryStream();
doc.Save(msStream, SaveFormat.Html);
msStream.Position = 0;
StreamReader reader = new StreamReader(msStream);
ReadText(reader);

But I cannot use the physical path in my code. Please provide me a solution to create an instance of Document with a Stream which accepts byte array.

Looking for a prompt reply Wink [;)]

You need to reposition the stream to the beginning:

ms.Position = 0;

before loadinig document with

Aspose.Words.Document doc = new Aspose.Words.Document(ms);

Best regards,

Hi!

We are delighted to announce the availability of Aspose.Words for SharePoint, which is our latest addition to the Aspose.Words product family.

This release, Aspose.Words for SharePoint 1.0 makes high quality document conversions for DOC/DOCX/ODT/RTF/PDF/XPS and others easily accessible to SharePoint users.

Please find more details in our Documentation area.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(7)