Copy slides without master

Hi … iam trying to copy slides from multiple presentations to one single presentation. All presentation share the same slidemaster but each clone brings his own copy of the slidemaster.


Is there a way to create a new presentation with a single master and just add the other slides as content without the master?

I need a way in ppt and pptx.

thanks,
btauber

Hi Btauber,

Thanks for inquiring Aspose.Slides.

I have understand the requirements shared by you and like to share that in case of PPTX slide cloning there is option to set the Master slide on slide cloning level. If you use the default slide clone method, it will copy the respective slide master as well in target presentation. However, if your use slides.addClone(sourceSlide, MasterSlide) method, it will clone slide with master that you are trying to set and will not copy the rest. However, in case of PPT cloning, the master slide will be copied along with cloned slide and it is logical as there must be a master slide for the slide to be cloned.

So,once you will clone all the slides, you can call the following methods in your presentation and delete all the unused masters as well.

Presentation newPresentation = new Presentation();
newPresentation.deleteUnusedMasters();
PresentationEx pptx = new PresentationEx();
pptx.getMasters().removeUnused(true);

Please visit this link for PPTX slide cloning.

Many Thanks,

Hi … thank you for your quick reply.


Iam really struggeling with this for hours now. Iam not getting the results I expect.

Here ist what iam trying to do. (PPT). I build some sample presentations for your to reproduce my mistakes. They are attached to this post. I can send you my complete test classes if you want to take a closer look at my code.

1. I created a new Presentation Object (target) with my “master2.ppt” as template:
new Presentation("…/master2.ppt");

2. I copied all slides of “source.ppt” to my target Presentation. In each slide I copied I replaced the master with the one from my target Presentation:
Slide sourceslide = presentation.getSlideByPosition(fromIndex);

sourceslide = presentation.cloneSlide(sourceslide, toIndex, target, new TreeMap();

Slide master = target.getMainMaster();
  sourceslide.changeMaster(master);</code></div><div><code>target.deleteUnusedMasters();</code></div><div><br></div><div>3. I wrote the target presentation to file system and removed the unused slide from my "master2.ppt" template. </div><div><br></div><div><div><code>Slide toRemove = this.presentation.getSlideByPosition(this.presentation.getSlides().size());</code></div><div><code>this.presentation.getSlides().remove(toRemove);</code></div><div><code>this.presentation.write(new FileOutputStream(file));</code></div></div><div><code><br></code></div><div>Can you please take a look at the result presenation and explain to me why I and up with more than 20 master slides?? I really dont get what Iam doing wrong. </div><div><br></div><div>thank you .. </div><div>btauber</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">	</span></div>

Hi Btauber,


I have worked over the requirements shared by you and have created the sample code for your convenience. The code snippet is able to retain only one master slide and removing the one from source presentation. For your kind reference, I have also share the generated presentation as well.

public static void AddPPTClone() throws Exception
{

try {
String path=“D:\Aspose Data\master\”;
//Load the source presentation
Presentation srcPres = new Presentation(“D:\Aspose Data\master\source.ppt”);
//Instantiate the target presentation
Presentation targetPres = new Presentation(“D:\Aspose Data\master\master2.ppt”);
Slide clonedSlide=null;
java.util.TreeMap treeMap=new java.util.TreeMap();
Slide MasterSlide=targetPres.getSlideById(targetPres.getSlideByPosition(1).getMasterId());
//Clone the source presentation to the target
for (int i = 1; i <= srcPres.getSlides().getLastSlidePosition();i++)
{
clonedSlide=srcPres.cloneSlide(srcPres.getSlideByPosition(i),targetPres.getSlides().getLastSlidePosition() + 1, targetPres, treeMap);
clonedSlide.changeMaster(MasterSlide, true);
}
//Removing Default slide
targetPres.getSlides().removeAt(0);
//Write the target presentation
targetPres.deleteUnusedMasters();
targetPres.write(path+“ClonedpresentationNew.ppt”);
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

Many Thanks,

Hi, thank you for sharing your code example. Did you use my master2.ppt file as template?

If I look at your created ppt file, the master still looks strange to me. Why has every master slide a backgroundimage when there was only the titlemaster who has a background image in my master2.ptt?

I attached a screenshot of what Iam seeing.

Maybe I need to know more about powerpoint but the results look suprising to me :slight_smile:

Another question:
How can I assign a specific layout of a my master to a slide? My first slide should get my title layout and the other slides should get content layout?

I know I have many questions … but thank you for looking into this
btauber

Hi Btauber,


Thanks for elaboration. I have observed the requirement shared by you. Your observation is that the layout slides in slide master are getting increased after slide cloning as compared to source master slide layouts. Also, the background image is getting replicated on all other layout slides instead of actual one only. I have created an issue with ID SLIDESJAVA-33506 in our issue tracking system to further investigate the issue on our end.

Secondly, I like to share that currently support for changing the layout slides for PPT presentation slides is unavailable and an issue with ID SLIDESJAVA-33505 has been created as new feature request to investigate the issue further on our end.

This thread has been linked with the issue so that you may be automatically notified once the issues will be resolved.

Many Thanks,

The issues you have found earlier (filed as SLIDESJAVA-33506) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as SLIDESJAVA-33505) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.