Aspose.Slides for C++
Contents
[
Hide
]
Aspose.Slides for C++ 是一套原生 C++ 函式庫,可用於建立、讀取、編輯與轉換 PowerPoint 與 OpenDocument 簡報,無需 Microsoft PowerPoint 或 Office Automation。
它載入並儲存 PPT、PPTX、PPS、POT 與 ODP,包括支援巨集與範本變體,並匯出為 PDF、XPS、HTML、SVG、TIFF、Markdown 與影像。
使用 Slides 建置
常見任務
Slides 工作流程
範例
您的第一個簡報
在 Windows 上,於 Visual Studio 建立 C++ Console App 專案,並在「套件管理員主控台」(Tools > NuGet Package Manager > Package Manager Console) 中安裝 NuGet 套件:
Install-Package Aspose.Slides.Cpp
在 Linux 上,下載 Linux ZIP 套件,並依照 Installation 中的說明設定 CMake 專案。
然後使用以下程式碼作為您的主要原始檔。此程式會建立一個包含文字方塊的簡報並儲存:
#include <DOM/Presentation.h>
#include <DOM/ISlide.h>
#include <DOM/IShapeCollection.h>
#include <DOM/IAutoShape.h>
#include <DOM/ITextFrame.h>
#include <DOM/ShapeType.h>
#include <Export/SaveFormat.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;
int main()
{
auto presentation = MakeObject<Presentation>();
auto slide = presentation->get_Slide(0);
auto shape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 50, 400, 100);
shape->get_TextFrame()->set_Text(u"Hello, Aspose.Slides!");
presentation->Save(u"hello.pptx", SaveFormat::Pptx);
presentation->Dispose();
return 0;
}
在 Windows 執行時,於工具列選取 x64 平台並按下 Ctrl+F5。在 Linux 上,將程式碼儲存為 main.cpp 放置於專案資料夾,然後編譯並執行:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/hello
此程式會將 hello.pptx 儲存為一張包含文字方塊的投影片。若未取得授權,儲存的檔案會帶有評估水印——請參閱 Licensing。欲了解更多建立與填寫簡報的方式,請參考 Create Presentations。