Copy (clone) slide from one presentation to another presentation

Hello,

We’re trying (evaluating) with Aspose Slides for Java, version 14.5.0, to copy (clone) a slide with a layout from one presentation to a new presentation. We’ve used the example “In Another Presentation with Master Slide from Source Presentation at the End of the Existing Slides” on page Clone Slides|Aspose.Slides Documentation. Unfortunately, the result slide has not the same layout as the original. What are we doing wrong? Are we missing something?

This is our code:

import com.aspose.slides.*;

public class CopyOneSlide {

    public static void main(String[] args) {
        //Instantiate Presentation class to load the source presentation file
        Presentation srcPres = new Presentation("Welkom bij PowerPoint.pptx");

        //Instantiate Presentation class for destination presentation (where slide is to be cloned)
        Presentation destPres = new Presentation();

        //Instantiate ISlide from the collection of slides in source presentation along with
        //master slide
        ISlide SourceSlide = srcPres.getSlides().get_Item(0);

        //Clone the desired master slide from the source presentation to the collection of masters in the
        //destination presentation
        IMasterSlideCollection masters = destPres.getMasters();
        IMasterSlide SourceMaster = SourceSlide.getLayoutSlide().getMasterSlide();

        //Clone the desired master slide from the source presentation to the collection of masters in the
        //destination presentation
        IMasterSlide iSlide = masters.addClone(SourceMaster);

        //Clone the desired slide from the source presentation with the desired master to the end of the
        //collection of slides in the destination presentation
        ISlideCollection slds = destPres.getSlides();
        slds.addClone(SourceSlide, iSlide);

        //Clone the desired master slide from the source presentation to the collection of masters in the//destination presentation
        //Save the destination presentation to disk
        destPres.save("welkom.pptx", SaveFormat.Pptx);
    }
}

Tia,
Michelle
Sendrata

Hi Michelle,

Thanks for inquiring Aspose.Slides.

I have observed your requirements and request you to please share the sample presentation, generated presentation and desired output presentation. I will investigate the issue further on my end to help you out.

Many Thanks,

Hi Mudassir,

Thanks for your reply!

I’ve attached 3 files: “Welkom bij PowerPoint.pptx”, the source pptx, “Generated Presentation.pptx” and “Desired Presentation.pptx”. The source pptx is a public presentation of MicroSoft. We use this presentation in our evaluation process of software that can help us extract slides from a presentation and merge slides from different presentations to a new presentation. The real presentations we work with are not public but we have the same problem with these presentations. So if we can fix this for the source presentation, i’m sure we can also fix this for our real presentations.

The generated presentation has 2 slides, that should only be 1, but we know how to remove the first slide. That’s no problem. The problem we have is the size of the generated slide. The title in the orange block seems to be good, but the slide it self seems to be smaller. I hope there’s a simple solution to solve this.

Thanks for your help!

Michelle
Sendrata


Hi Sendrata,

Thank you for sharing the files.

We are looking into your issue and will get back to you soon.

Thanks & Regards,

Hi Owais,

I think we have found the solution. We thought it had something to do with the size of the slides. So we have searched and found in an example of C# that we can copy the slide size from the source presentation to the destination presentation.

Translated to Java, we’ve added the following line:

destPres.getSlideSize().setSize(srcPres.getSlideSize().getSize());
This solved the problem.

Thanks for your help!

Michelle
Sendrata

Hi Sendrata,

Thank you for the feedback.

We are glad to know that you are able to resolve the issue at your end. Please feel free to contact support in case you need any further assistance.

Thanks & Regards,