빠른 시작

빠른 시작

이 가이드는 CMake 설정부터 .pptx 파일을 저장하는 가장 빠른 경로를 보여줍니다. C++용 aspose_slides_foss을 사용합니다. 이 라이브러리는 MIT 라이선스를 따르며 Microsoft Office가 필요 없고, C++20 컴파일러와 CMake 3.20 이상이 설치된 모든 플랫폼에서 빌드됩니다.


전제 조건

요구 사항세부 사항
C++ 표준C++20 이상
CMake3.20 이상
OSWindows, macOS, Linux
Packageaspose_slides_foss를 CMake를 통해 FetchContent

Install

구성 시점에 라이브러리를 가져오기 위해 CMake FetchContent를 사용합니다. 다음을 CMakeLists.txt에 추가하고 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)

프레젠테이션 만들기

Presentation를 인수 없이 생성하여 빈 덱을 만든 다음, 경로와 SaveFormat::PPTX를 사용해 save()을 호출합니다. 라이브러리는 자동으로 빈 슬라이드 하나를 추가합니다:

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

텍스트가 포함된 도형 추가

첫 번째 슬라이드에 prs.slides()[0]를 사용하여 접근하고, shapes().add_auto_shape()을(를) 이용해 사각형을 삽입한 뒤, 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;
}

단색 채우기 적용

도형에 대해 fill_format().set_fill_type(FillType::SOLID)를 호출하고, solid_fill_color().set_color()을 통해 ARGB 색상을 제공한 뒤 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;
}

기존 파일 로드

Presentation 생성자에 파일 경로 문자열을 전달하여 기존 .pptx 파일을 로드합니다. 필요에 따라 데크를 수정한 후 save()를 호출하여 출력을 기록합니다:

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

다음 단계

참조

 한국어