Out of memory exception while converting large docx file to pdf


We are using Aspose-words 22.10 with java version 8 on Windows 10.
While converting docx file to pdf we are getting out of memory error on our server.
File size is around 24 MB.

This is not for all the files only specific file is giving such error.
Could you please suggest how can we resolve it?


@rutuja.mahajan Could you please attach your document here for testing? We will check the issue and provide you more information. Have you tried increasing java heap space? For reducing memory usage upon processing extremally large documents, you can try using LoadOptions.TempFolder , SaveOptions.TempFolder and SaveOptions.MemoryOptimization properties.

Please note, Aspose.Words always allocates more memory that actual document size. This is expected. Please see our documentation for more information:

I am not able to upload the file, tried with zip as well, file size is 24mb.
Any other way to upload?

@rutuja.mahajan You can upload the file to google drive and provide a link to download it.


Here is the google drive link to download input document.

@rutuja.mahajan Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side using the latest 24.4 version of Aspose.Words for Java. The document is converted to PDF without any issues using the following simple code:

Document doc = new Document("C:\\Temp\\in.docx");


Using latest Aspose words 24.4 version I am getting this exception,
java.lang.ClassCastException: com.aspose.words.zzWnV cannot be cast to com.aspose.words.zzYvu

Any dependent jar is required to resolve this?

@rutuja.mahajan No, there are no additional dependencies required. I cannot reproduce the exception with the document you shared earlier. Does it occur with the same document on your side?

Yes, it is for same document.

@rutuja.mahajan Could you please zip and share it again as archive. Probably google drive changed something in the document.