SmartArt
Contents
[
Hide
]
本文示範如何使用 Aspose.Slides for Python via Java 新增 SmartArt 圖形、存取它們、移除它們,以及變更版面配置。
請按照安裝中的說明安裝套件。每個範例會在啟動 JVM 之前匯入 asposeslides,然後在 JVM 運行後匯入 API。
新增 SmartArt
Insert a SmartArt graphic using one of the built-in layouts.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SmartArtLayoutType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
smart_art = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess)
finally:
presentation.dispose()
存取 SmartArt
Retrieve the first SmartArt object on a slide.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SmartArt, SmartArtLayoutType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
smart_art = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess)
first_smart_art = None
for index in range(slide.getShapes().size()):
shape = slide.getShapes().get_Item(index)
if isinstance(shape, SmartArt):
first_smart_art = shape
break
finally:
presentation.dispose()
移除 SmartArt
Delete a SmartArt shape from the slide.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SmartArtLayoutType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
smart_art = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicProcess)
slide.getShapes().remove(smart_art)
finally:
presentation.dispose()
變更 SmartArt 版面配置
Update the layout type of an existing SmartArt graphic.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Presentation, SmartArtLayoutType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
smart_art = slide.getShapes().addSmartArt(50, 50, 400, 300, SmartArtLayoutType.BasicBlockList)
smart_art.setLayout(SmartArtLayoutType.VerticalPictureList)
finally:
presentation.dispose()