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

Free Support Forum - aspose.com

java.lang.NegativeArraySizeException

Hi,

When we try to convert PPTX file to PNG Thumbnail image, it gives "java.lang.NegativeArraySizeexception". Full stack trace is

java.lang.NegativeArraySizeException

at com.aspose.slides.obfuscated.fi.do(SourceFile:34)

at com.aspose.slides.obfuscated.vf.try(SourceFile:65)

at com.aspose.slides.obfuscated.vf.new(SourceFile:60)

at com.aspose.slides.obfuscated.vf.(SourceFile:47)

at com.aspose.slides.obfuscated.ad.do(SourceFile:34)

at com.aspose.slides.obfuscated.ad.(SourceFile:30)

at com.aspose.slides.Presentation.do(SourceFile:178)

at com.aspose.slides.Presentation.(SourceFile:534)

Can you please let us know what could be the issue. We are using latest version of aspose 2.4.2.

We dont face this issue on PPT format of file. Please let me know in case any other information is required.

Regards,

Aman

Dear Aman,

I have investigated the stack trace shared by you. However, in order to add the issue in our issue tracking system for resolution, I need to reproduce the issue on my end and for that I request you to please share the source presentation file so that we may proceed further. I appreciate your cooperation in advance.

Thanks and Regards,

Hi Aspose team,

I have created a small java program. However it is giving heap space issue. I have given 2048 in my meory arguments.

Please find below the java program and attach is the PPTX file which i used

-----------------------------------

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Date;
import javax.imageio.ImageIO;
import com.aspose.slides.pptx.PresentationEx;
import com.aspose.slides.pptx.SlideEx;
import com.aspose.slides.pptx.SlidesEx;

public class AsposeConvertBackground {

public static void main(String[] args) {

try {
PresentationEx pres = new PresentationEx("d:\\test_ppt.pptx");
SlidesEx s = pres.getSlides();
SlideEx sld = s.get(0);
BufferedImage bf = sld.getThumbnail(790,650);
ImageIO.write(bf, "jpg", new File("d:\\test_ppt.jpg"));
}
catch (Exception e) {

e.printStackTrace();
}


}

}
---------------------------------

Regards,

Aman

Hello Dear,

I have investigated the code snippet share by and have found an inconsistency in that. Actually, you have chosen the image size to be 790/650 in X/Y direction. This value actually doesn't correspond to pixels but in fact it is the scaling factor. If you select 1f/1f in X/Y direction then the default image that will be created, have size 720x540. Now, by simple calculation, if we look at the example used by you the generated image resolution will be 790*720 x 650*540. The generated image size will be of 5.81 GB. That is why you are obtaining the heap exception. Hope it answers your query.

BufferedImage bf = sld.getThumbnail(790,650);

Thanks and Regards,

Hi,

Thanks for the information. So does that mean, Aspose generates Buffered Image from power point file differently for Presentation and PresentationEX?

Regards,

Aman

Dear Aman,

I don't feel that there is any difference in generating slide thumbnails for Presentation and PresenationEx classs. You can pass the scale factor in constructor getThumbnail() method of both images. However, the getThumbnail() method of Presentation class has some other overloads that involve setting the dimension of the thumbnail. Please proceed to link 1 and link 2 for further details.

Thanks and Regards,

Hi I am getting the exception while converting my pptx to pdf

here i attach my source code

import com.aspose.slides.Presentation;
import com.aspose.slides.export.SaveFormat;
public String execute() throws IOException
{
try{
Presentation pres=new Presentation(“D:/Hello.ppt”);
pres.save(“d:/demo.pdf”,SaveFormat.PDF);
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return “success”;
}

Hi Dhirajkumar,


Thank you for your interest in Aspose.Slides.

I have observed your comments and like to request you to please make a separate post over this link and share your issue details along with the source file to reproduce the issue because sometimes the issue look similar but causes are different. Please share with us the requested details in separate thread so that, we may proceed further to help you out.

Best Regards,