Frequently Asked Questions
Frequently Asked Questions
How do I build and link Aspose.Slides FOSS for C++?
Use CMake FetchContent to add the library to your project. C++20 or later is required.
cmake_minimum_required(VERSION 3.20)
project(my_app LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
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)
add_executable(my_app main.cpp)
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?
Slide background color is not exposed in the current API. BaseSlide and Slide do not have a background() method. This feature is not available in this edition of the library.
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);
// Note: set_font_underline() takes TextUnderlineType, not NullableBool:
// fmt.set_font_underline(Aspose::Slides::Foss::TextUnderlineType::NONE);
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);