I am using ASPOSE.Word(6.0.0.1) , and also Used latest version as ASPOSE.Word(6.1.0.0), For creating Images of pages from the Word document. I am using SaveToImage method of Aspose.Words.Document.
I save the document file in a SQL Database into Memeory Stream format.When i am going to upload document file of 3-4MB(Or more than this) its gives me error as “System.OutOfMemoryException”.
Hi
Thank you for additional information. I cannot reproduce “OutOfMemory” exception. However, “Index out of range” exception occurs when I use your code, because there is a small mistake. This code works fine on my side:
Public Sub ConvertToImages(ByVal docs As MemoryStream)
Dim srcDoc As New Aspose.Words.Document(docs)
' PageCount-1 because zero based index is used
For i As Integer = 0 To srcDoc.PageCount - 1
Dim stream As MemoryStream = New MemoryStream()
srcDoc.SaveToImage(i, 1, stream, Imaging.ImageFormat.Bmp, Nothing)
'i saved images to file
Dim imgFile As FileStream = New FileStream(String.Format("C:\Temp\pages\p_{0}.bmp", i), FileMode.Create)
stream.WriteTo(imgFile)
imgFile.Close()
Next
End Sub