Sign In  Sign Up Live-Chat

Splitting a file

Last post 09-05-2008, 12:18 AM by Mohans. 3 replies.
Sort Posts: Previous Next
  •  11-27-2006, 2:32 PM 62176

    Splitting a file

    I want to split a powerpoint file, so that there is 1 file per slide. I want to do this for several files

    Also I want to then take some of these files and create a new presentation

    Can I do this?

     

     
  •  11-28-2006, 5:36 AM 62235 in reply to 62176

    Re: Splitting a file

    Sure, you can. All these things can be done through creating empty presentation and cloning slides.
    This short example will save all slides as separate ppt files:

    for (int i = 1; i <= srcPres.Slides.LastSlidePosition; i++)
    {
        // Create new presentation and clone slide
        Presentation newPres = new Presentation();
        srcPres.CloneSlide(srcPres.GetSlideByPosition(i), 2, newPres, new SortedList());
        // Delete first empty slide
        newPres.Slides.Remove(newPres.GetSlideByPosition(1));
        // Save created presentation with one slide to a new file
        newPres.Write("slide" + i + ".ppt");
    }


    Alexey Zhilin
    Team Leader
    Aspose Tyumen Team
    About Us
    Contact Us
     
  •  09-04-2008, 3:31 PM 142482 in reply to 62235

    Re: Splitting a file

    The above code written by Alexey is in C#, below is the equivalent code in Java.

     

    JAVA

    ----------------------------------------------------

    //Read the source presentation

    Presentation srcPres=new Presentation(new FileInputStream("c:\\source.ppt"));

    int lastSlidePosition=srcPres.getSlides().getLastSlidePosition();

    for (int i = 1; i <= lastSlidePosition; i++)

    {

    // Create new presentation and clone slide

    Presentation newPres = new Presentation();

    //Make slide size equal in both presentation

    newPres.setSlideSize(srcPres.getSlideSize());

    // Clone the slide from source into new presentation

    Slide srcSld=srcPres.getSlideByPosition(i);

    srcPres.cloneSlide(srcSld, 2, newPres, new TreeMap());

    // Delete first empty slide

    newPres.getSlides().remove(newPres.getSlideByPosition(1));

    // Save created presentation with one slide to a new file

    newPres.write(new FileOutputStream("c:\\slide" + i + ".ppt"));


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
  •  09-05-2008, 12:18 AM 142527 in reply to 142482

    Re: Splitting a file

    Thanks Shakeel Faiz. I was looking for the same code. it really works fine for me. It helped me a lot

    Thanks,

    Mohans

     
View as RSS news feed in XML