We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

OutOfMemoryException - Aspose.Words for .Net

Hello,

We're having OutOfMemoryException when opening a .doc file and a .docx file and saving them to pdf. Both documents contain scanned pages that have been pasted into the text as images.
It is the only similarity I've been able to find.

Exception of type 'System.OutOfMemoryException' was thrown.
Stack trace: at Aspose.Words.Document.ԁ(Stream Ӿ, LoadFormat ӿ, String Ԁ)
at Aspose.Words.Document.ӽ(Stream Ӿ, LoadFormat ӿ, String Ԁ)
at Aspose.Words.Document..ctor(Stream stream, String baseUri, LoadFormat loadFormat, String password)
at Aspose.Words.Document..ctor(Stream stream)
at VGC.Sharepoint.Lib.AsposeUtil.ConvertFileToPDF(String SiteUrl, String Library, String Filename)

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Could you attach the documents you are getting issues with? I will check the problem on my side and provide you more information.

Best regards,

Unfortunately, due to the sensitive nature of these documents, I cannot send them to you.
The only thing I can do is describe them : The problem occurred both with a doc file and a docx file.
Both had scanned pages pasted into the text as images. One document was 1.53 Mb and the other 3.97 Mb, so the filesize itself was not overly large.

Hopefully this tells you enough to reconstruct the problem.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. It is safe to attach files in the forum. If you attach your document here, only you and Aspose staff members can download it. Moreover, you can make this thread private. In this case, nobody except you and Aspose staff will be able to see this thread.

Unfortunately, it is difficult to say what the problem is without the document. I need this document to reproduce the problem on my side.

Best regards,

I've been given permission to add the documents in question. Hopefully this will help you.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.1.0). You can download this version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

There is 4Gb of RAM on my side.

Best regards,

We've checked the system on our side and it seems we're running version 8.0.0.
Would you please try and see if you can reproduce the problem using that version?

That way we can be certain that it is that version of aspose that is causing the problem
and not just install a new version just because it's a new version.

We've had problems with that in the past with other tools and would like to avoid it this time.

Best regards,

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I have tested with Aspose.Words 8.0.0 and I still cannot reproduce the problem on my side. I use the following code for testing:

Document doc = new Document("yourDoc.doc");

doc.SaveToPdf("out.pdf");

Best regards,

Hello,

This is the code we use:

Stream streamtoconvert = SPListItem.File.OpenBinaryStream();
Document doctoConvert = new Document(streamtoconvert); <-- the error occurs here.
streamtoconvert.Close();
Stream convertedstream = new MemoryStream();
doctoConvert.Save(convertedstream, SaveFormat.Pdf);

The sourcefile is a document attached to a SPListItem.
Once the stream is converted it is added to the list, again as a stream.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I still cannot reproduce the problem. Please try using the following code:

using (FileStream fs = File.OpenRead(@"C:\Temp\Collegebesluit+bijlage+1.doc"))

{

// Open docuemnt from stream

Document doc = new Document(fs);

// Save docuemnt as PDF into another stream.

MemoryStream convertedstream = new MemoryStream();

doc.SaveToPdf(0, doc.PageCount, convertedstream, null);

}

Best regards,

Thank you for all your help, but we continue to have this problem.

Maybe it's time to look beyond the code and try to find the cause elsewhere.
Are there other things (hardware or software) that could affect the proper function of this code?

Any ideas you might have on this would be welcome.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Could you please try using the latest version of Aspose.Words 9.4.0 and let me know how it goes on your side.

I cannot provide you any additional information about this problem, because I cannot reproduce it on my side. If it is possible, could you please create simple application which will allow me to reproduce the problem on my side?

Best regards,