Sectie

Voorbeelden voor het beheren van presentatiesecties — toevoegen, openen, verwijderen en hernoemen via code met Aspose.Slides for PHP via Java.

Sectie toevoegen

Maak een sectie die begint op een specifieke dia.

function addSection() {
    $presentation = new Presentation();
    try {
        $slide = $presentation->getSlides()->get_Item(0);

        // Geef de dia op die het begin van de sectie aangeeft.
        $presentation->getSections()->addSection("New Section", $slide);

        $presentation->save("section.pptx", SaveFormat::Pptx);
    } finally {
        $presentation->dispose();
    }
}

Sectie openen

Lees sectie‑informatie uit een presentatie.

function accessSection() {
    $presentation = new Presentation("section.pptx");
    try {
        // Toegang tot een sectie via index.
        $section = $presentation->getSections()->get_Item(0);
        $sectionName = $section->getName();
    } finally {
        $presentation->dispose();
    }
}

Sectie verwijderen

Verwijder een eerder toegevoegde sectie.

function removeSection() {
    $presentation = new Presentation("section.pptx");
    try {
        $section = $presentation->getSections()->get_Item(0);

        // Verwijder de sectie.
        $presentation->getSections()->removeSection($section);

        $presentation->save("section_removed.pptx", SaveFormat::Pptx);
    } finally {
        $presentation->dispose();
    }
}

Sectie hernoemen

Verander de naam van een bestaande sectie.

function renameSection() {
    $presentation = new Presentation("section.pptx");
    try {
        $section = $presentation->getSections()->get_Item(0);
        $section->setName("New Name");

        $presentation->save("section_renamed.pptx", SaveFormat::Pptx);
    } finally {
        $presentation->dispose();
    }
}