Getting Out of memory error from ASPOSE

Hi there,

We are getting out of memory error while trying to converting attached file into HTML content using ASPOSE API, even though the size of the file is not too large and could not find any large image embedded in it. Could you please help us understanding the cause of this issue? PFB the stack trace.

java.lang.OutOfMemoryError
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:699)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1342)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1563)
at javax.imageio.ImageIO.read(ImageIO.java:1430)
at asposewobfuscated.bp.d(Image.java:191)
at asposewobfuscated.bp.a(Image.java:171)
at asposewobfuscated.bp.b(Image.java:158)
at asposewobfuscated.bp.b(Image.java:144)
at com.aspose.words.qy.us(ImageTransform.java:60)

We are using the old version of ASPOSE, the code to convert file into HTML content is as below.

Document destdocument = new Document(file_input_stream);
destdocument.getSaveOptions().setHtmlExportImagesFolder(strFolder);
destdocument.save(htmlStream, SaveFormat.HTML); 

Regards,

Ashish

This message was posted using Email2Forum by aske012. (attachment)

Hi Ashish,

Thanks for you inquiry.

I have tried reproducing issue on my end using your input word document, but was not able to reproduce any issue with the latest version (ver 11.11.0) of Aspose.Words for Java. The code you have used is tweaked a bit and here is the updated code used by us during verification of issue:

String csPath = "C:/TempFolder/";
// Open the stream and Document. Read only access is enough for Aspose.Words to load a document. InputStream stream = new FileInputStream(csPath + "Advanced+Services+Style+Guide-1.docx"); Document destdocument = new Document(stream);
// This is the directory we want the exported images to be saved to. File imagesDir = new File(csPath, "Images");
// The folder specified needs to exist and should be empty. if (imagesDir.exists()) imagesDir.delete(); 
imagesDir.mkdir();
// Set an option to save as HTML and specify Images directory. HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML); options.setImagesFolder(imagesDir.getPath());
// Save output HTML OutputStream htmlStream = new FileOutputStream(csPath + "Advanced+Services+Style+Guide-1.html"); destdocument.save(htmlStream, options); 

The generated html document along with the Images directory is attached in the zip file to the reply also. I would also recommend you to please use the latest version of Aspose.Words for Java. You can download latest version here.

Hope this helps. Please do let us know how does it go on your side or if you have any more queries.