เริ่มต้นอย่างรวดเร็ว
เริ่มต้นอย่างรวดเร็ว
คู่มือนี้แสดงเส้นทางที่เร็วที่สุดจากการตั้งค่า CMake ไปยัง Save .pptx ไฟล์ที่ใช้ aspose_slides_foss สําหรับ C++ ห้องสมุดมีใบอนุญาต MIT ไม่ต้องการ Microsoft Office, และสร้างบนแพลตฟอร์มใด ๆ ที่มีคอมพิลเลอร์ C++20 และ CMake 3.20 หรือหลังกว่านี้.
Prerequisites
| Requirement | Detail |
|---|---|
| มาตรฐาน C++ | C++20 หรือหลังกว่านี้ |
| CMake | 3.20 or later |
| OS | Windows, macOS, ลินักซ์ |
| Package | aspose_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)สร้าง การ นําเสนอ
Construct Presentation โดยไม่มีอาร์กูเมนต์ที่จะสร้างเกมบอลเปล่า, แล้วเรียก save() มีเส้นทางและ SaveFormat::PPTX.ห้องสมุดจะเพิ่มสไลด์ว่าง 1 ภาพโดยอัตโนมัติ:
#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>
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;
}ใช้ เติม ที่ มั่นคง
Call fill_format().set_fill_type(FillType::SOLID) ในรูปและการจัดหาของ สี ARGB ผ่าน solid_fill_color().set_color() ก่อนโทรหา 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>
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 แผนแปลง Deck ตามที่ต้องการ แล้วเรียก save() เพื่อเขียน output:
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/export/save_format.h>
int main() {
Presentation prs("existing.pptx");
prs.save("copy.pptx", SaveFormat::PPTX);
return 0;
}