We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Templates in Slides

Hey Hi All,

first of all really thanks to all you guys , you built really cool API.

Now i am again using Aspose Slides so can some one guide me how to use templates in Aspose and one more thing i tries to read one existing PPT and using this as a template so its removing all existing sections.

please guide me how to use templates in Aspose.

Thanks & Regards
Setu Agrawal

Hi Setu,

Thanks for your interest in Aspose.Slides.

We are sorry for the delayed response. Please use the code snippet below, that will help you in loading presentation templates and applying them on presentation slides. For your reference, I have also attached the sample templates, source and output PPT files.

    String dirPath = "D:\\ppt\\ ";
    Presentation srcTemplate = new Presentation(new FileInputStream(dirPath+"Template2.pot"));
    Presentation srcPres = new Presentation(new FileInputStream(dirPath+"source.ppt"));

    TreeMap temp = new TreeMap();

    //Clone slide from template to import master and delete extraneous slide
    Slide sld=srcTemplate.cloneSlide(srcTemplate.getSlideByPosition(1), srcPres.getSlides().getLastSlidePosition() + 1, srcPres, temp);


    //Save the master id of the newly cloned slide
    //Slide sld=srcTemplate.getSlideByPosition(1);

    long mstrId = sld.getMasterId();

    //Delete the extraneous slide

    //Get the master slide
    Slide mstrSld = srcPres.getSlideById(mstrId);

    //Change the master of all the normal slides in source presentation
    for (int i = 1; i <= srcPres.getSlides().getLastSlidePosition(); i++)
        Slide normSld = srcPres.getSlideByPosition(i);
        normSld.changeMaster(mstrSld, true);

    //Write presentation on disk
    srcPres.write(new FileOutputStream(dirPath+"OutputpresMud.ppt"));
catch(Exception ex)

Thanks and Regards,

Hey Hi Mudassir,

Gr8 help thanks man, you explained really in good way.

Thanks & regards
Setu Agrawal