بخش

نمونه‌هایی برای مدیریت بخش‌های ارائه—اضافه کردن، دسترسی، حذف و تغییر نام آن‌ها به‌صورت برنامه‌نویسی با استفاده از Aspose.Slides for Python via Java.

پکیج را همانطور که در Installation توضیح داده شده نصب کنید. هر مثال قبل از شروع JVM asposeslides را ایمپورت می‌کند، سپس پس از اجرای JVM API را ایمپورت می‌کند.

افزودن یک بخش

یک بخش ایجاد کنید که از اسلاید خاصی شروع می‌شود.

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation

presentation = Presentation()
try:
    slide = presentation.getSlides().get_Item(0)

    # اسلایدی که آغاز بخش را نشان می‌دهد.
    presentation.getSections().addSection("New Section", slide)
finally:
    presentation.dispose()

دسترسی به یک بخش

اطلاعات بخش را از یک ارائه بخوانید.

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpile.startJVM()

from asposeslides.api import Presentation

presentation = Presentation()
try:
    slide = presentation.getSlides().get_Item(0)

    presentation.getSections().addSection("My Section", slide)

    # دسترسی به بخش بر اساس ایندکس.
    section = presentation.getSections().get_Item(0)
    section_name = section.getName()
    print(section_name)
finally:
    presentation.dispose()

حذف یک بخش

یک بخش که قبلاً اضافه شده است را حذف کنید.

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation

presentation = Presentation()
try:
    slide = presentation.getSlides().get_Item(0)

    section = presentation.getSections().addSection("Temporary Section", slide)

    # حذف اولین بخش.
    presentation.getSections().removeSection(section)
finally:
    presentation.dispose()

تغییر نام یک بخش

نام یک بخش موجود را تغییر دهید.

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation

presentation = Presentation()
try:
    slide = presentation.getSlides().get_Item(0)

    presentation.getSections().addSection("Old Name", slide)

    section = presentation.getSections().get_Item(0)
    section.setName("New Name")
finally:
    presentation.dispose()