מהיר התחלה

מהיר התחלה

מדריך זה מראה את הדרך המהירה ביותר מהגדרת CMake אל הצלחה .pptx שימוש ב-File aspose_slides_foss עבור C++. הספרייה מורשית על ידי MIT, לא דורשת Microsoft Office, ובכל פלטפורמה עם C++20 קופלר ו- CMake 3.20 או מאוחר יותר.


דרישות

דרישותפרטים
C++ סטנדרטיםC++20 או מאוחר יותר
קמאה3.20 or later
OSWindows, MacOS ו- Linux
חבילהaspose_slides_foss באמצעות CMake FetchContent

Installer

שימוש במגביים 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 אין שום סיבה ליצור דבק לבן, אז להתקשר save() עם מסלול ו SaveFormat::PPTX.הספרייה מוסיפה באופן אוטומטי תמונה ריקה אחת:

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

הוסף צורה עם טקסט

גישה ל-Slide הראשון דרך 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) על צורה ומספקת צבע 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>

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

שלבים הבאים

ראה גם

 עברית