Frequently Asked Questions

Frequently Asked Questions

Frequently Asked Questions

How do I build and link Aspose.Slides FOSS for C++?

Clone the repository and build with CMake. C++17 or later is required.

git clone https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
cd Aspose.Slides-FOSS-for-Cpp
mkdir build && cd build
cmake ..
cmake --build .

In your project’s CMakeLists.txt, link against the library:

find_package(AsposeSlideFoss REQUIRED)
target_link_libraries(my_app PRIVATE aspose-slides-foss)

No Microsoft Office or other system runtime is required.


Why must I use RAII with Presentation?

The Presentation class manages internal XML resources. When the object goes out of scope, its destructor releases those resources. Avoid allocating a Presentation with new without a smart pointer; use stack allocation or std::unique_ptr to ensure cleanup.

Always follow this pattern:

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

int main() {
    Aspose::Slides::Foss::Presentation prs;
    // work here
    prs.save("output.pptx", Aspose::Slides::Foss::SaveFormat::PPTX);
    return 0;
}

What file formats can I save to?

Only PPTX is supported:

prs.save("output.pptx", Aspose::Slides::Foss::SaveFormat::PPTX);

Export to PDF, HTML, SVG, or image formats (PNG, JPEG) is not available in this edition.


Can I open .ppt (old PowerPoint 97-2003) files?

No. Only .pptx (Office Open XML) files are supported. Legacy .ppt binary format is not handled by this library.


How do I access slides?

Slides are a zero-based collection accessible via prs.slides():

auto& slides = prs.slides();
auto& first_slide = slides[0];
auto count = slides.size();

How do I add a second slide?

Use prs.slides().add_empty_slide() with a layout:

Aspose::Slides::Foss::Presentation prs;
auto& layout = prs.layout_slides()[0];
prs.slides().add_empty_slide(layout);
auto& slide2 = prs.slides()[1];
prs.save("two-slides.pptx", Aspose::Slides::Foss::SaveFormat::PPTX);

How do I set the slide background color?

Access slide.background().fill_format():

auto& slide = prs.slides()[0];
slide.background().fill_format().set_fill_type(Aspose::Slides::Foss::FillType::SOLID);
slide.background().fill_format().solid_fill_color().set_color(
    Aspose::Slides::Foss::Color::from_argb(255, 230, 240, 255));

How do I use NullableBool?

NullableBool is a tri-state enum used for formatting properties. Use NullableBool::TRUE (not C++ true) for bold, italic, and similar properties:

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

fmt.set_font_bold(Aspose::Slides::Foss::NullableBool::TRUE);
fmt.set_font_italic(Aspose::Slides::Foss::NullableBool::FALSE);
fmt.set_font_underline(Aspose::Slides::Foss::NullableBool::NOT_DEFINED); // inherits from theme

Why does setting text color have no effect?

You must also set fill_type to SOLID before assigning the color:

fmt.fill_format().set_fill_type(Aspose::Slides::Foss::FillType::SOLID);
fmt.fill_format().solid_fill_color().set_color(
    Aspose::Slides::Foss::Color::from_argb(255, 200, 0, 0));

Can I use charts or SmartArt?

No. Charts, SmartArt, OLE objects, animations, transitions, hyperlinks, VBA macros, and digital signatures are not implemented in this edition.


Is this library thread-safe?

Each Presentation object is independent. Creating and using separate Presentation instances from separate threads is safe as long as you do not share a single Presentation object across threads without external locking.


How do I embed an image?

Read the image bytes and add them to prs.images(), then create a PictureFrame:

#include <Aspose/Slides/Foss/presentation.h>
#include <fstream>
#include <vector>

std::ifstream file("logo.png", std::ios::binary);
std::vector<uint8_t> data((std::istreambuf_iterator<char>(file)),
                           std::istreambuf_iterator<char>());
auto& image = prs.images().add_image(data);
slide.shapes().add_picture_frame(
    Aspose::Slides::Foss::ShapeType::RECTANGLE, 50, 50, 200, 150, image);

See Also