Quick Start

Quick Start

This guide shows the fastest path from CMake setup to a saved .pptx file using aspose_slides_foss for C++. The library is MIT-licensed, requires no Microsoft Office, and builds on any platform with a C++20 compiler and CMake 3.20 or later.


Prerequisites

RequirementDetail
C++ standardC++20 or later
CMake3.20 or later
OSWindows, macOS, Linux
Packageaspose_slides_foss via CMake FetchContent

Install

Use CMake FetchContent to pull the library at configure time. Add the following to your CMakeLists.txt and then link against aspose_slides_foss:

include(FetchContent)
FetchContent_Declare(
    aspose_slides_foss
    GIT_REPOSITORY https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
    GIT_TAG main
)
FetchContent_MakeAvailable(aspose_slides_foss)
target_link_libraries(your_target PRIVATE aspose_slides_foss)

Create a Presentation

Construct Presentation with no arguments to create a blank deck, then call save() with a path and SaveFormat::PPTX. The library automatically adds one empty slide:

#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs;
    prs.save("empty.pptx", SaveFormat::PPTX);
    return 0;
}

Add a Shape with Text

Access the first slide via prs.slides()[0], insert a rectangle with shapes().add_auto_shape(), and set its text via text_frame()->set_text():

#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/shape_type.h>
#include <Aspose/Slides/Foss/text_frame.h>
#include <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs;
    auto& slide = prs.slides()[0];
    auto& shape = slide.shapes().add_auto_shape(
        ShapeType::RECTANGLE, 50, 50, 400, 150
    );
    shape.text_frame()->set_text("Hello from Aspose.Slides FOSS!");
    prs.save("with_shape.pptx", SaveFormat::PPTX);
    return 0;
}

Apply a Solid Fill

Call fill_format().set_fill_type(FillType::SOLID) on the shape and supply an ARGB color via solid_fill_color().set_color() before calling save():

#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/fill_format.h>
#include <Aspose/Slides/Foss/fill_type.h>
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/shape_type.h>
#include <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs;
    auto& shape = prs.slides()[0].shapes().add_auto_shape(
        ShapeType::RECTANGLE, 100, 100, 400, 200
    );
    shape.fill_format().set_fill_type(FillType::SOLID);
    shape.fill_format().solid_fill_color().set_color(0xFF, 0x46, 0x82, 0xB4);
    shape.text_frame()->set_text("Styled shape");
    prs.save("styled.pptx", SaveFormat::PPTX);
    return 0;
}

Load an Existing File

Pass a file path string to the Presentation constructor to load an existing .pptx file. Modify the deck as needed and then call save() to write the output:

#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs("existing.pptx");
    prs.save("copy.pptx", SaveFormat::PPTX);
    return 0;
}

Next Steps