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

Free Support Forum - aspose.com

Need upgrade assistance

I’m upgrading from Slides 7.9.0 to 15.8.1 and I’ve changed all the PresentationEx to Presentation, but it appears that there is no Write method for the Presentation class. Our code uses PresentationEx.Write to write a presentation to a MemoryStream.

How do I do this with the new unified API?

Hi Michael,


Thank you for your interest in Aspose.Slides.


I have observed your comments and like to request you to please try using following sample code on your end to serve the purpose.


var stream = File.OpenRead("D:\\Test.pptx");

var fileBytes = new byte[stream.Length];

MemoryStream memoryStream = new MemoryStream(fileBytes);

memoryStream.Position = 0;

stream.Read(fileBytes, 0, fileBytes.Length);

stream.Close();

var pptxDoc = new Presentation(memoryStream);


pptxDoc.Save(“D:\Test.pptx”, Aspose.Slides.Export.SaveFormat.Pptx);


I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,

Hi Michael,


Thanks for getting back to us.

I have observed the requirements shared by you and like to share that in New API the postfix Ex in SlideEx class has been replaced by prefix I and now you need ISlide class to access the slide. Similarly the PresenationEx can be accessed using IPresentaiton or Presentaiton class. Please visit this documentation link to serve the purpose in this regard. Please also visit this documentation section for your kind reference as well.

Many Thanks,

Thank you for the quick response. Here is the code that worked under 7.9:





public static byte[] GetBytesFromPresentation(PresentationEx presentation)

{

byte [] bytes = null;

MemoryStream ms = null;



try

{

ms = new MemoryStream();

presentation.Write(ms);

ms.Seek(0, SeekOrigin.Begin);

bytes = new byte[ms.Length];

ms.Read(bytes, 0, (int)ms.Length);

}



finally

{

if(ms != null)

{

ms.Close();

ms.Dispose();

}

}

return bytes;

}



When I change the type of the parameter from PresentationEx to Presentation, it tells me that Presentation does not have a Write method.



How do I update this code to work with the new API?

Hi Michael,

I have observed the requirements shared and like to share that the PresentationEx.Write method has been replaced by Presentation.Save method. If you please observe the documentation links that I have shared, you will get an idea about that as well.

Many Thanks,

Thanks, I didn’t notice that Save had an overload that accepted a stream object.

Everything is working now.

Hi Michael,


Thank you for your valuable feedback.

We are glad to know that your issue is resolved and things have started working on your end. Please feel free to contact us if we could be of any help to you.

Best Regards,