SmartArt

این مقاله نشان می‌دهد که چگونه گرافیک‌های SmartArt را اضافه کنید، به آن‌ها دسترسی داشته باشید، حذف کنید و طرح‌بندی‌ها را با استفاده از Aspose.Slides for Python via Java تغییر دهید.

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

افزودن SmartArt

یک گرافیک SmartArt را با استفاده از یکی از طرح‌بندی‌های پیش‌ساخته درج کنید.

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

اولین شیء SmartArt موجود در یک اسلاید را بازیابی کنید.

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

یک شکل SmartArt را از اسلاید حذف کنید.

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

نوع طرح‌بندی یک گرافیک SmartArt موجود را به‌روزرسانی کنید.

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()