適用於 .NET 的 Python 版 Aspose.Slides
Contents
[
Hide
]
Aspose.Slides for Python via .NET 是一個用於建立、讀取、編輯及轉換 PowerPoint 與 OpenDocument 簡報的 Python 函式庫,無需 Microsoft PowerPoint 或 Microsoft Office。
它可載入與儲存 PPT、PPTX、PPS、POT 以及 ODP,包含支援巨集與範本的變體,並可匯出為 PDF、XPS、HTML、SVG、TIFF、Markdown 以及影像。
使用 Slides 建置
常見任務
Slides 工作流程
範例
您的第一個簡報
Install the package from PyPI:
pip install aspose.slides
此套件已包含它所使用的 .NET 執行環境,因此您無需自行安裝 .NET。在 Linux 上,還需要安裝 libgdiplus 與 ICU 函式庫,若使用 Debian 或 Ubuntu 的系統 Python,請在虛擬環境中執行指令。macOS 有其他先決條件,我們尚未驗證該平台的安裝。請參閱Installation 了解指令、macOS 先決條件以及支援的 Python 版本。
Save this code as hello.py:
import aspose.slides as slides
# 實例化表示簡報檔案的 Presentation 類別。
with slides.Presentation() as presentation:
# 取得第一張投影片。
slide = presentation.slides[0]
# 加入類型為 CLOUD 的自動圖形。
auto_shape = slide.shapes.add_auto_shape(slides.ShapeType.CLOUD, 20, 20, 200, 80)
auto_shape.text_frame.text = "Hello, Aspose!"
# 將簡報儲存為 PPTX 檔案。
presentation.save("new_presentation.pptx", slides.export.SaveFormat.PPTX)
使用 python hello.py 執行它。此腳本會在目前資料夾中儲存 new_presentation.pptx,其中包含一張帶有雲狀圖形且文字為「Hello, Aspose!」的投影片。未取得授權時,儲存的檔案會帶有評估浮水印——請參閱Licensing。欲了解更多建立與填充簡報的方法,請參閱Create Presentations。