How to Сonvert ISlide to IMasterSlide with Aspose.Slides for .NET?

Hi,
I’m trying to clone slides to master slides.
What I want to do in detail is to copy each slide in a source presentation,and then put them as master slides in a target presentation.
I’ve tried the code below to do this.

Presentation targetpres = new Presentation("Put The Path of the Target Presentation Here");
Presentation sourcepres = new Presentation("Put The Path of the Source Presentation Here");
for (var index_src = 0; index_src < sourcepres.Slides.Count; index_src++)
{
    ISlide sourceslide = sourcepres.Slides[index_src];
    IMasterSlide convert = (IMasterSlide)sourceslide;
    targetpres.Masters.InsertClone(index_src, convert);
}

However,it doesn’t work since ISlide can’t be converted to IMasterSlide by using “IMasterSlide convert = (IMasterSlide)sourceslide;”.
Could you please tell me whether it’s possible to clone slides to master slides?
For instance,can I just simply loop through every shape in the source slide and clone them to a newly-created master slide,so that it looks like the source slide is “copied”?

@Loui,
Thank you for describing the issue. I am working on your questions and will get back to you ASAP.

@Andrey_Potapov
Thank you so much for replying me. :heartbeat:
Have you worked it out now?

@Loui,
It looks like presentation slides cannot be easy converted to master slides using Aspose.Slides.

As a workaround, this should work, but the IMasterSlideCollection does not allow adding new empty master slides.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-43761

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@Loui,
Please try using the following code snippet:

using (var tempPres = new Presentation()) // It contains an empty master slide that can be copied safely.
using (var sourcePres = new Presentation(sourcePresPath))
using (var targetPres = new Presentation(targetPresPath))
{
    foreach (var slide in sourcePres.Slides)
    {
        // Clone the master slide from the temporary presentation.
        var masterSlide = targetPres.Masters.AddClone(tempPres.Masters[0]);

        // Clear the new master slide.
        masterSlide.Shapes.Clear();
        masterSlide.LayoutSlides.RemoveUnused();

        // Copy shapes from the slide to the master slide.
        foreach (var shape in slide.Shapes)
            masterSlide.Shapes.AddClone(shape);
    }

    targetPres.Save(targetPresPath, SaveFormat.Pptx);
}

Does this workaround work for you?