Free Support Forum - aspose.com

Exception "Null Ref" when Rendering Slide to Graphic using Aspose.Slides for Java

Hi,

using this code

ISlide slide = presentation.Slides[slideIndex];
Bitmap bitmap = new Bitmap(thumbnailInfo.Width, thumbnailInfo.Height, PixelFormat.Format32bppArgb);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
slide.RenderToGraphics(null, graphics, thumbnailInfo.Width, thumbnailInfo.Height);
return bitmap;
}

we get a null reference exception while trying to render the first slide of the following presentation:
presentation.zip (25.5 KB)

Could you please take a look.
Thanks.

Best regards
Christopher Black

@blackChristopher,

I have observed the issue shared by you and have been able to reproduce the issue specified. An issue with ID SLIDESJAVA-37014 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

@Adnan.Ahmad:
Just to make sure.
It is great you could reproduce it for Java, but the same seems to be happening with the .NET Variant of slides as well, which is the case I am having.

Best regards
Christopher Black

@blackChristopher,

I have observed your comments. Can you please share complete sample code so that we can reproduce issue on our end. Also please share environment details with us along with which Aspose.Slides version you are using on your end.

@Adnan.Ahmad,
since we found a workaround we will not invest any time in reproducability, but it is the same code used in the first post just in a .NET Application.

Best regards
Christopher Black

@blackChristopher,

I have observed your comments. Can you please try to use below sample code and share feedback with us if there is still an issue. I also like to inform that you used null for INotesCommentsLayoutingOptions in RenderToGraphics method:

slide.RenderToGraphics(null, graphics, 960, 540);

But the method RenderToGraphics can’t use null as INotesCommentsLayoutingOptions.

ISlide slide = presentation.Slides[slideIndex];
Bitmap bitmap = new Bitmap(thumbnailInfo.Width, thumbnailInfo.Height, PixelFormat.Format32bppArgb);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
INotesCommentsLayoutingOptions options = new NotesCommentsLayoutingOptions();
slide.RenderToGraphics(options, graphics, thumbnailInfo.Width, thumbnailInfo.Height);
return bitmap;
}

The issues you have found earlier (filed as SLIDESJAVA-37014) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz