セクション

プレゼンテーションのセクションを管理する例 — 追加、アクセス、削除、名前変更をプログラムで 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():
    jpype.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()