Schnelle Start
Schnelle Start
Dieser Leitfaden zeigt den schnellsten Weg von CMake-Setup zu einem gesparten .pptx Datei verwenden aspose_slides_foss für C++. Die Bibliothek ist MIT-Lizenz, erfordert keine Microsoft Office, und auf jeder Plattform mit einem C++20 Compiler und CMake 3.20 oder später baut.
Voraussetzungen
| Anforderung | Details |
|---|---|
| C++ Standard | C++20 oder später |
| CMAC | 3.20 or later |
| OS | Windows, MacOS und Linux |
| Packung | aspose_slides_foss über CMake FetchContent |
Installation
Verwenden Sie CMAK FetchContent die Bibliothek zu konfigurieren Zeit zu ziehen. fügen Sie die folgenden Für Ihre CMakeLists.txt Und dann Link gegen 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)Erstellen Sie eine Präsentation
Konstruktion Presentation ohne Argumente, um einen weißen Deck zu erstellen, dann rufen Sie save() Mit einem Weg und SaveFormat::PPTX.Die Bibliothek fügt automatisch einen leeren Slide hinzu:
#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;
}Ein Form mit Text hinzufügen
Zugang zum ersten Slide über prs.slides()[0],Einfach einen Rechteck mit shapes().add_auto_shape(),und setzen Sie den Text über 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;
}Ein solides Fill anwenden
Anruf fill_format().set_fill_type(FillType::SOLID) in Form und Lieferung einer ARGB Farbe über solid_fill_color().set_color() Vor der Anrufe 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;
}Laden Sie ein vorhandenes Datei
Passen Sie eine Datei-Path-Straße auf die Presentation Der Bauhersteller laden eine bestehende .pptx Datei. Änderung der Decke, wie nötig und dann rufen save() Um die Ausgabe zu schreiben:
#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;
}