Rýchly začiatok

Rýchly začiatok

Táto príručka ukazuje najrýchlejšiu cestu od nastavenia CMake k uloženému programu. .pptx súbor pomocou aspose_slides_foss pre C++. knižnica je licencovaná na základe MIT, nevyžaduje Microsoft Office., a stavia sa na akejkoľvek platforme s C++20 kompilátorom a CMake 3.20 alebo novším.


Predpoklady

PožiadavkaPodrobnosti
Štandard C++C++20 alebo novší
CMake3.20 or later
OSWindows, macOS, Linux
Balík:aspose_slides_foss cez CMake FetchContent

Inštalácia

Použite CMake FetchContent Pri nastavení vytiahnuť knižnicu. Pridať nasledujúce: na vaše CMakeLists.txt a potom prepojiť proti 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)

Vytvorte prezentáciu

Vytvorenie Presentation bez argumentov vytvoriť prázdny balík, potom volať save() s cestou a SaveFormat::PPTX.Knižnica automaticky pridá jedno prázdne snímky:

#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;
}

Pridať tvar s textom

Prístup k prvému diapozitivu prostredníctvom prs.slides()[0], vložiť obdĺžnik s shapes().add_auto_shape(), a nastaviť jej text prostredníctvom: 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;
}

Používajte pevné plnenie

Zavolajte . fill_format().set_fill_type(FillType::SOLID) na tvar a dodávku a Farba ARGB prostredníctvom: solid_fill_color().set_color() pred volaním . 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;
}

Nahradenie existujúceho súboru

Predajte reťazce cesty súboru do . Presentation Konstruktor na zaťaženie existujúceho .pptx Zmeniť balíček podľa potreby a potom volajte save() na zapísanie výstupu:

#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;
}

Ďalšie kroky

 Slovenčina