Good Afternoon.
Hi Geoff,
Thanks for inquiring Aspose.Slides.
I have observed the requirement shared by you and will try to share both workaround and reason with you. Actually, the slide is not an only entity inside the presentation document object model. Every slide has some master or layout slide associated with it. Also, if there are any images added in the slides they are actually added in presentation image collection but referred in the slide only. So a slide cannot be treated as a separate entity as it does not have the complete picture inside it. But it is one of the important part of the whole picture. I hope this will elaborate the concept before you. So, if you want to serialize, you can save the entire presentation instead of single slide as presentation involves every thing inside it.
Now, coming to solution that I can offer you to get things going on your end. You have requirement of serializing independent slide in database. Aspose.Slides offers the solution of slide cloning or copying. You can use Aspose.Slides to access the every single slide of source presentation copy that independently in some temporary PresentationEx object and then saving the single slide presentation in memory stream. Then converting that memory stream to byte array and populating that to database along with file extension in separate field for future retrieval of the byte array. When you will need to access that slide added in database, you will have to load the byte array and convert that to memory stream. Then load the memory stream back in to PresentationEx. I hope this will help. I have shared the sample code for exporting individual slide to Memory Stream for your kind reference.
public static void changetoMemStream()
{
PresentationEx origPres = new PresentationEx("SamplePres.pptx");
PresentationEx tempPres = null;
foreach (SlideEx slide in origPres.Slides)
{
tempPres = new PresentationEx();
tempPres.Slides.AddClone(slide);
tempPres.Slides.RemoveAt(0);
MemoryStream mem = new MemoryStream();
tempPres.Save(mem, Aspose.Slides.Export.SaveFormat.Pptx);
mem.Position = 0;
byte[] buffer = new byte[mem.Length];
mem.Write(buffer, 0, (int)mem.Length);
}
}
Please also visit this documentation link for more insight on slide cloning feature that you will be needing when copying slides to and from presentation. Please share, if I may help you further in this regard.
Many Thanks,
Good Morning Mudassir
Hi Geoff,
Thanks for sharing the further information.
I like to share that earlier you shared that you need save the individual slide to presentation. So, I shared the solution that worked in that particular scenario.
With some more information shared from you what I have perceived is that you actually wish to show the available slides graphically in some user interface (UI). The user will select the list of slides in UI and on back end the presentation will be generated with selected slides in UI. I hope that I am getting your requirement right up till here.
I like to share that Aspose.Slides manages presentations programatically and there is no front end associated with it. The only way available to depict slides in UI is by generating thumbnails and maintaining some link of thumbnails with slides on back end for references and further implementation of your logic. The implementation plan shared by you in second part of your query is exactly doable and is in fact the only possible solution in your’s mentioned application type.
In the scenario mentioned, you may also not need to even keep the slides as separate entities in databases and saving them as byte array there as it would cost your performance. The better would be to use the presentations stored on your disk and you devise some mechanism on back end that the particular thumbnail selected in UI from user is actually belonging to which presentation and what slide index. With this information available, you would simply clone that slide to your target presentation for the user. Now, coming to your concern about the master slides associated with slides when they are clone. Actually, whenever the slide is cloned using a default clone method, it gets cloned in target presentation with its master and layout slides. This is logical as you need to see exactly the same slide what you have in source presentation. Aspose.Slides also offers you to change the master applied on the slide and apply any template master on cloned slides. If you change the master of any cloned slide in target presentation there is also a provision to delete unused master slides as well inside target presentation to avoid growing presentation size.
I have already shared the documentation link for managing different options available in Slide cloning in my previous post and you can explore them on your end. I also like to add that slide cloning does not take that much time it is efficient process. I also like to share that on normal server, creating a 20 slide presentation wont take that much time. The CPU touching 100% depends upon the server type used on your end and I may not be able to quantify this for you unless you test this in your environment. Also the web server or other server settings may also take part in it. As per my personal experience on my laptop, cloning of 20 slides complete about in minuet or so. But this also depends upon the contents of slides. If there is heavy multimedia content on slide in the form of video, audio and big images. They certainly play their role.
I am sorry, I may not help you OpenXML SDK inquiry. Please share, if I may help you further in this regard.
Many Thanks,
Hi Mudassir,
Hi Geoff,
Hi Mudassir