Aspose.Slides throws an exception during ppt-presentation opening

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi Aspose team.

I’m encountered a problem trying to open my presentation file using Aspose.Slides v5.2.0.0 library.

You can find PowerPoint file in the attachment. It was made in PowerPoint 2010 but saved as 2003 format. PowerPoint itself found no issues in the file.

When I’m executing the code below it falls into exception “Index was outside the bounds of the array.”

///

/// PowerPoint data processor for Aspose library

/// Perform reading/writing operations with Excel.

///

/// Array of bytes with PowerPoint file body

public PowerPointAsposeProcessor(byte[] fileData)

{

try

{

Stream stream = new MemoryStream();

stream.Write(fileData, 0, fileData.Length);

var loadOptions = new LoadOptions(LoadFormat.Ppt);

_presentation = new Presentation(stream, loadOptions);

stream.Dispose();

}

catch (Exception err)

{

LOG.Error(err);

}

}

Could you please investigate the reason of this issue and provide an update (if necessary)?

Thank you

Hi Andrew,

I have observed the code snippet. You are missing following statement in your code snippet. Please add the statement after you have written the byte array in stream and before you are accessing the stream in presentation.

stream.Write(fileData, 0, fileData.Length);

stream.Position = 0;

Thanks and Regards,

Wow, my bad. Thank you for immediate response. Everything works fine now.
PS: strange, but Aspose.Cells works fine without setting position, that’s why I’ve missed it in my code.
In any case thank you for clarification.