can you provide a sample code in java to merge different powerpoint presentation from a directory into a single presentation . help will be very much appreciated .
Dear Yasheel,
Please see this thread.
<A href="https://forum.aspose.com/t/100277</A></P>
Given is a code which i tried to run to get 5 ppt containing one slide each and merge them into a single ppt with all the slides in it . But i am able to get two slides one being the first ppt slide and other being a slide with aspose watermark inside the final ppt .
import com.aspose.slides.;
import java.io.;
import java.util.*;
public class Consolidate {
public static void main(String args[]) {
try
{
File dir = new File(“c:\test”);
String[] children = dir.list();
if (children == null) {
System.out.println(" **** Directory is Empty ****");
} else {
for (int i=0; i<children.length; i++) {
String filename = children[i];
if(!filename.endsWith(".ppt")){
break;
}
Presentation srcPres = new Presentation(new FileInputStream( dir + “/” + filename ));
Presentation newPres = new Presentation();
TreeMap ids = new TreeMap();
for (int slides = 1 ; slides <= newPres.getSlides().size(); slides++) {
ids.clear();
newPres.cloneSlide(newPres.getSlideByPosition(slides), srcPres.getSlides().getLastSlidePosition()+1, srcPres, ids);
}
srcPres.write(new FileOutputStream(“c:\output\newslide.ppt”));
}
}
}
catch(Exception e)
{
System.out.print(e.toString());
}
}
}
please do show me how to get rest of the ppt slides as it is an immediate issue . Thank you .
Here is the corrected code.
try
{
Presentation newPres = new Presentation();
File dir = new File("c:\\test");
String[] children = dir.list();
if (children == null) {
System.out.println(" **** Directory is Empty ****");
} //end if
else {
for (int i=0; i<children.length; i++) {
String filename = children[i];
if(!filename.endsWith(".ppt")){
break;
}//end if
Presentation srcPres = new Presentation(new FileInputStream( dir + "/" + filename ));
TreeMap ids = new TreeMap();
for (int slides = 1 ; slides <= srcPres.getSlides().getLastSlidePosition(); slides++) {
//ids.clear();
srcPres.cloneSlide(srcPres.getSlideByPosition(slides), newPres.getSlides().getLastSlidePosition()+1, newPres, ids);
}//end for
}//end for
//Remove one extra slide
newPres.getSlides().remove(newPres.getSlideByPosition(1));
//Delete unused handouts and masters
newPres.deleteUnusedMasters();
newPres.deleteHandout();
newPres.write(new FileOutputStream("c:\\output\\newslide.ppt"));
}//end else
}//end Try
catch(Exception e)
{
System.out.print(e.toString());
}//end Catch
thank you it worked … thanks alot …