Search code examples
phppowerpointopentbs

OpenTBS copy slide and create a new pptx file


I am using OpenTBS. I want to copy slides from a pptx file and create separate pptx file for each slide.

e.g. if there is pptx file of 10 slides. I want to split it to create pptx file for each slide. So there will be 10 pptx files.

Can anyone share a example how can I do this in OpenTBS?


Solution

  • You cannot create or copy a new slide in a PPTX using OpenTBS. But you can delete as many slide you want.

    So the solution is to delete all slides but one from the template, and this doing this for each PPTX you have to make.

    Example :

    $TBS = new clsTinyButStrong;
    $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN);
    
    for ($i = 1 ; $i <= 10 ; $i++) {
    
        $TBS->LoadTemplate('my_template.pptx');
        
        $slides_to_deleted = range(1, 10);
        array_splice($slides_to_deleted, ($i - 1), 1); // delete 1 item at index ($i - 1)
        $TBS->PlugIn(OPENTBS_DELETE_SLIDES, $slides_to_deleted);
        
        $TBS->Show(OPENTBS_FILE, "merged_{$i}.pptx");
        
    }