Раздел

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

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

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

def add_section():
    with slides.Presentation() as presentation:
        slide = presentation.slides[0]

        # Добавьте новый раздел и укажите слайд, обозначающий начало раздела.
        presentation.sections.add_section("New Section", slide)

        presentation.save("section.pptx", slides.export.SaveFormat.PPTX)

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

Получите раздел из презентации.

def access_section():
    with slides.Presentation("section.pptx") as presentation:

        # Доступ к разделу по индексу.
        section = presentation.sections[0]

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

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

def remove_section():
    with slides.Presentation("section.pptx") as presentation:
        section = presentation.sections[0]

        # Удалить раздел.
        presentation.sections.remove_section(section)

        presentation.save("section_removed.pptx", slides.export.SaveFormat.PPTX)

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

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

def rename_section():
    with slides.Presentation("section.pptx") as presentation:
        section = presentation.sections[0]

        # Переименовать раздел.
        section.name = "New Name"

        presentation.save("section_renamed.pptx", slides.export.SaveFormat.PPTX)