Раздел

Примеры управления разделами презентации — добавление, доступ, удаление и переименование их программно с помощью Aspose.Slides for PHP via Java.

Добавить раздел

Создайте раздел, который начинается с определённого слайда.

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

        // Укажите слайд, который отмечает начало раздела.
        $presentation->getSections()->addSection("New Section", $slide);

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

Доступ к разделу

Прочитайте информацию о разделе из презентации.

function accessSection() {
    $presentation = new Presentation("section.pptx");
    try {
        // Доступ к разделу по индексу.
        $section = $presentation->getSections()->get_Item(0);
        $sectionName = $section->getName();
    } finally {
        $presentation->dispose();
    }
}

Удалить раздел

Удалите ранее добавленный раздел.

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

        // Удалить раздел.
        $presentation->getSections()->removeSection($section);

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

Переименовать раздел

Измените имя существующего раздела.

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();
    }
}