Introduction
Aspose.Slides FOSS for C++ (aspose_slides_foss) is a free, open-source C++20 library for creating and manipulating PowerPoint presentations programmatically. Built entirely in native C++ with no external runtime dependencies beyond CMake 3.20+, it gives developers full control over PPTX files without requiring Microsoft Office or any proprietary software.
The library is released under the MIT license, making it suitable for both commercial and non-commercial projects. The public API lives in the Aspose::Slides::Foss namespace and provides a rich object model covering presentations, slides, shapes, tables, text frames, document properties, comments, and PPTX export.
This post walks through the core API surface: the classes and methods you will use most often when building, formatting, and saving presentations.
What’s Included
Presentation and Slide Management
The Presentation class is the entry point. Creating a new instance gives you a default slide that is immediately ready for content. You access slides through the SlideCollection returned by slides(), which supports indexed access, iteration, removal, and reordering.
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation pres;
auto& slide = pres.slides()[0]; // first slide
// Work with the slide...
pres.save("output.pptx", SaveFormat::PPTX);
Shapes and AutoShapes
Every slide exposes a ShapeCollection through its shapes() accessor. The collection provides factory methods for adding different shape types: add_auto_shape for standard geometry shapes (rectangles, ellipses, triangles), add_connector for line connectors, add_table for tables, and add_picture_frame for images.
auto& slide = pres.slides()[0];
// Add a rectangle
auto& rect = slide.shapes().add_auto_shape(
ShapeType::RECTANGLE, 50, 50, 300, 100);
// Add an ellipse
auto& ellipse = slide.shapes().add_auto_shape(
ShapeType::ELLIPSE, 400, 50, 150, 150);
// Add a connector between shapes
auto& conn = slide.shapes().add_connector(
ShapeType::BENT_CONNECTOR3, 0, 0, 1, 1);
The ShapeCollection also supports size(), remove(), remove_at(), reorder(), index_of(), and clear() for managing shapes after creation.
Text and Paragraph Formatting
Shapes can hold text via TextFrame. Use add_text_frame() on an AutoShape to attach text content, or access the existing frame through text_frame(). Text is organized into paragraphs, each containing one or more portions. The BasePortionFormat class exposes font styling properties including bold, italic, underline type, capitalization, strikethrough, and font color.
auto& shape = pres.slides()[0].shapes().add_auto_shape(
ShapeType::RECTANGLE, 50, 50, 300, 100, false);
shape.add_text_frame("Hello, world!");
auto text = shape.text_frame()->text(); // "Hello, world!"
Fill, Gradient, and Visual Effects
Each shape provides a FillFormat accessible via fill_format(). You can set solid fills, gradient fills, or pattern fills through the set_fill_type() method. Gradient fills are configured through the GradientFormat object, which supports linear angles, gradient shape, and color stops via GradientStopCollection.
auto& shape = slide.shapes().add_auto_shape(
ShapeType::RECTANGLE, 50, 50, 300, 150);
shape.fill_format().set_fill_type(FillType::GRADIENT);
auto& gf = shape.fill_format().gradient_format();
gf.set_gradient_shape(GradientShape::LINEAR);
gf.set_linear_gradient_angle(45);
gf.gradient_stops().add(0.0f, Color::blue);
gf.gradient_stops().add(1.0f, Color::red);
The EffectFormat class (accessed via effect_format()) adds glow, outer shadow, and soft edge effects. Each effect is enabled with a dedicated method (enable_glow_effect(), enable_outer_shadow_effect(), enable_soft_edge_effect()) and configured through its returned object.
Tables
Tables are created with add_table() on the shape collection. You supply column widths and row heights as vectors. The returned Table object exposes rows() and columns() collections, and individual Cell objects support text content via TextFrame.
std::vector<double> col_widths = {100, 150, 200};
std::vector<double> row_heights = {40, 40, 40};
auto& table = slide.shapes().add_table(
50, 50, col_widths, row_heights);
// table.rows().size() == 3
// table.columns().size() == 3
Document Properties and Comments
The DocumentProperties class lets you set metadata such as title, author, subject, keywords, category, revision number, and timestamps. Access it through the presentation object.
Comments are managed through CommentAuthorCollection and CommentCollection. You add authors with add_author(), then attach comments to specific slides at specific coordinates.
Presentation pres;
auto& author = pres.comment_authors().add_author("Alice", "A");
auto& slide = pres.slides()[0];
auto& comment = author.comments().add_comment(
"Review note", slide, PointF(2.0f, 3.0f), now);
Quick Start
Building from Source
The library requires CMake 3.20+ and a C++20-capable compiler. Clone the repository and build:
git clone https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
cd Aspose.Slides-FOSS-for-Cpp
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
Minimal Example
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
int main() {
Presentation pres;
auto& slide = pres.slides()[0];
// Add a shape with text
auto& shape = slide.shapes().add_auto_shape(
ShapeType::RECTANGLE, 50, 50, 300, 100, false);
shape.add_text_frame("Hello from Aspose.Slides FOSS!");
// Apply a solid fill
shape.fill_format().set_fill_type(FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(Color::blue);
// Save
pres.save("hello.pptx", SaveFormat::PPTX);
return 0;
}
Supported Formats
The SaveFormat enum defines all export targets. The following formats are confirmed in the source code:
| Format | Extension | Read | Write |
|---|---|---|---|
| PPTX | .pptx | – | Yes |
| PPT | .ppt | – | Planned |
| PPSX | .ppsx | – | Planned |
| PPTM | .pptm | – | Planned |
| PPSM | .ppsm | – | Planned |
| POTX | .potx | – | Planned |
| POTM | .potm | – | Planned |
| POT | .pot | – | Planned |
| PPS | .pps | – | Planned |
| ODP | .odp | – | Planned |
| OTP | .otp | – | Planned |
| FODP | .fodp | – | Planned |
| – | Planned | ||
| XPS | .xps | – | Planned |
| HTML | .html | – | Planned |
| HTML5 | .html | – | Planned |
| TIFF | .tiff | – | Planned |
| GIF | .gif | – | Planned |
| SWF | .swf | – | Planned |
| MD | .md | – | Planned |
| XML | .xml | – | Planned |
Note: Currently only PPTX export is implemented. Other format values exist in the SaveFormat enum for forward compatibility but are not yet functional. The save() method always produces PPTX output regardless of the format parameter.
Open Source & Licensing
Aspose.Slides FOSS for C++ is released under the MIT license. You can use it freely in personal projects, commercial applications, and redistributed libraries. There are no API keys, watermarks, or usage limits. The full source code is available on GitHub at https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.
Getting Started
Ready to integrate Aspose.Slides FOSS into your C++ project? Here are the key resources:
- Documentation: https://docs.aspose.org/slides/cpp/ for developer guides, tutorials, and conceptual overviews.
- Knowledge Base: https://kb.aspose.org/slides/cpp/ for FAQs and how-to articles covering common tasks.
- API Reference: https://reference.aspose.org/slides/cpp/ for class-by-class documentation of the full public API.