Introduction
Aspose.Slides FOSS for C++ (aspose_slides_foss) เป็นเว็บไซต์ที่ได้รับอนุญาตจาก MIT โดยไม่มีค่าใช้จ่าย ห้องสมุดสําหรับการสร้างและแก้ไข PowerPoint .pptx ไฟล์ในภาษา C++ เป็นพื้นบ้าน มันทํางานบน Windows, macOS และ Linux โดยไม่ขึ้นอยู่กับ Microsoft Office.
บทความ นี้ เปรียบเทียบ ลักษณะ สําคัญ ของ ฉบับ ใหม่ ที่ มี ใน ปัจจุบัน.
คุณสมบัติหลัก
การนําเสนอการโหลดและบันทึก
Presentation คือโอกซ์รูท สร้างมันโดยไม่มีอาร์กูเมนต์เพื่อสร้างไฟล์ใหม่ หรือส่งทางไฟล์เพื่ออัตราการโหลดที่มีอยู่. โทร save() มีเส้นทางและ SaveFormat เพื่อเขียน output:
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/export/save_format.h>
using namespace Aspose::Slides::Foss;
// Create new
Presentation prs;
prs.save("output.pptx", SaveFormat::PPTX);
// Load and save
Presentation prs2("existing.pptx");
prs2.save("copy.pptx", SaveFormat::PPTX);
การจัดการสไลด์
การ slides() method จะคืนการรวบรวมสไลด์. เพิ่มสไลด์ด้วย add_empty_slide(), เอาออกด้วย remove(), และเข้าถึงสไลด์ที่มีอยู่ตามอัตรา:
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/slide_collection.h>
#include <Aspose/Slides/Foss/export/save_format.h>
Presentation prs;
auto& slide = prs.slides()[0]; // First slide (created automatically)
// Add a second slide using the first master/layout
auto& layout = prs.masters()[0].layout_slides()[0];
auto& newSlide = prs.slides().add_empty_slide(layout);
prs.save("two_slides.pptx", SaveFormat::PPTX);
การใส่รูปแบบอัตโนมัติและข้อความ
เพิ่มรูปแบบโดยใช้ slide.shapes().add_auto_shape(). เข้าไปยังกรอบข้อความผ่าน shape.text_frame() เพื่อกําหนดเนื้อหาข้อความ:
#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/shape_collection.h>
#include <Aspose/Slides/Foss/shape_type.h>
#include <Aspose/Slides/Foss/slide.h>
#include <Aspose/Slides/Foss/slide_collection.h>
#include <Aspose/Slides/Foss/text_frame.h>
#include <Aspose/Slides/Foss/export/save_format.h>
Presentation prs;
auto& slide = prs.slides()[0];
auto& shape = slide.shapes().add_auto_shape(
ShapeType::RECTANGLE, 50, 50, 300, 100
);
shape.text_frame()->set_text("Hello from Aspose.Slides FOSS");
prs.save("shape_demo.pptx", SaveFormat::PPTX);
การ เติม ที่ แข็งแรง
Apply FillType::SOLID มีสี ARGB ในรูปแบบใดก็ได้:
#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>
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);
prs.save("solid_fill.pptx", SaveFormat::PPTX);
ผลประกอบภาพ
ใช้เงาภายนอก, แสงและอิฟเฟ็คด้านล่างที่นุ่มผ่าน shape.effect_format():
#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/effect_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>
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RECTANGLE, 100, 100, 300, 150
);
auto& ef = shape.effect_format();
ef.enable_outer_shadow_effect();
ef.outer_shadow_effect().set_blur_radius(8);
ef.outer_shadow_effect().set_distance(6);
ef.outer_shadow_effect().set_direction(45);
prs.save("shadow.pptx", SaveFormat::PPTX);
เริ่มต้นอย่างรวดเร็ว
บันทึกด้วยตัวเลือก:
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)
#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() {
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RECTANGLE, 50, 50, 400, 150
);
shape.text_frame()->set_text("My first slide");
prs.save("first.pptx", SaveFormat::PPTX);
return 0;
}
รูปแบบที่สนับสนุน
| Format | Extension | Read | Write |
|---|---|---|---|
| PPTX | .pptx | — | ✓ |
หลักสูตรและใบอนุญาต
Aspose.Slides FOSS for C++ is released under the MIT License. Build from source via การใช้งานทางการค้า, การกระจายใหม่ และการปรับเปลี่ยนทั้งหมดถูกอนุญาต.