ส่วน
Contents
[
Hide
]
ตัวอย่างการจัดการส่วนของงานนำเสนอ—เพิ่ม, เข้าถึง, ลบ, และเปลี่ยนชื่อโดยใช้ Aspose.Slides for Python via Java อย่างเป็นโปรแกรมมิ่ง
ติดตั้งแพคเกจตามที่อธิบายใน การติดตั้ง. ตัวอย่างแต่ละตัวจะนำเข้า asposeslides ก่อนเริ่ม JVM, แล้วจึงนำเข้า API หลังจาก JVM ทำงานแล้ว
เพิ่มส่วน
สร้างส่วนที่เริ่มที่สไลด์เฉพาะ
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
# ระบุสไลด์ที่เป็นจุดเริ่มต้นของส่วน.
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()