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