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.
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.
new Presentation("…/master2.ppt");
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,
public static void AddPPTClone() throws Exception{try {String path=“D:\Aspose Data\master\”;//Load the source presentationPresentation srcPres = new Presentation(“D:\Aspose Data\master\source.ppt”);//Instantiate the target presentationPresentation 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 targetfor (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 slidetargetPres.getSlides().removeAt(0);//Write the target presentationtargetPres.deleteUnusedMasters();targetPres.write(path+“ClonedpresentationNew.ppt”);}catch (Exception e){// TODO Auto-generated catch blocke.printStackTrace();}}
Hi, thank you for sharing your code example. Did you use my master2.ppt file as template?
Hi Btauber,
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.