C++ में PowerPoint में टिप्पणियाँ कैसे जोड़ें

C++ में PowerPoint में टिप्पणियाँ कैसे जोड़ें

Aspose.Slides FOSS for C++ दो एनोटेशन तंत्रों का समर्थन करता है:

  • Threaded comments: स्लाइड पर एक विशिष्ट स्थिति में संलग्न, PowerPoint के Review पेन में दिखाई देता है
  • Speaker notes: प्रति‑स्लाइड टेक्स्ट जो Presenter View और Notes पेन में दिखाई देता है

पूर्वापेक्षाएँ

git clone https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
cd Aspose.Slides-FOSS-for-Cpp && mkdir build && cd build
cmake .. && cmake --build .

एक टिप्पणी जोड़ें

टिप्पणियाँ एक author ऑब्जेक्ट से संबंधित हैं। पहले एक author बनाएं, फिर author.comments() के माध्यम से टिप्पणियाँ जोड़ें:

#include <Aspose/Slides/Foss/presentation.h>
#include <chrono>

int main() {
    namespace asf = Aspose::Slides::Foss;

    asf::Presentation prs;

    // Create a comment author with name and initials
    auto& author = prs.comment_authors().add_author("Jane Smith", "JS");

    auto& slide = prs.slides()[0];

    // Add a comment at position (2.0, 2.0) from the slide top-left
    Aspose::Slides::Foss::Drawing::PointF pos(2.0f, 2.0f);
    author.comments().add_comment(
        "Please review the figures on this slide",
        slide, pos, std::chrono::system_clock::now());

    prs.save("commented.pptx", asf::SaveFormat::PPTX);
    return 0;
}

PointF निर्देशांक स्लाइड के शीर्ष-बाएँ कोने से इंच में हैं। कई बार add_comment() को कॉल करने से समान लेखक के तहत एक थ्रेडेड टिप्पणी श्रृंखला बनती है।


एकाधिक लेखक और टिप्पणियाँ

#include <Aspose/Slides/Foss/presentation.h>

int main() {
    namespace asf = Aspose::Slides::Foss;

    asf::Presentation prs;
    auto& author1 = prs.comment_authors().add_author("Alice Brown", "AB");
    auto& author2 = prs.comment_authors().add_author("Bob Davis", "BD");

    auto& slide = prs.slides()[0];

    author1.comments().add_comment(
        "Initial draft: needs revision",
        slide, Aspose::Slides::Foss::Drawing::PointF(1.0f, 1.0f), std::chrono::system_clock::now());
    author2.comments().add_comment(
        "Approved after changes",
        slide, Aspose::Slides::Foss::Drawing::PointF(3.0f, 1.0f), std::chrono::system_clock::now());

    prs.save("multi-author.pptx", asf::SaveFormat::PPTX);
    return 0;
}

एक मौजूदा फ़ाइल से टिप्पणियाँ पढ़ें

#include <Aspose/Slides/Foss/presentation.h>
#include <iostream>

int main() {
    namespace asf = Aspose::Slides::Foss;

    asf::Presentation prs("commented.pptx");
    for (size_t i = 0; i < prs.comment_authors().size(); ++i) {
        auto& author = prs.comment_authors()[i];
        std::cout << "Author: " << author.name()
                  << " (" << author.initials() << ")\n";
        for (size_t j = 0; j < author.comments().size(); ++j) {
            auto& comment = author.comments()[j];
            std::cout << "  Slide " << comment.slide().slide_number()
                      << ": " << comment.text() << "\n";
        }
    }
    return 0;
}

स्लाइड में स्पीकर नोट्स जोड़ें

स्पीकर नोट्स slide.notes_slide_manager() के माध्यम से जोड़े जाते हैं:

#include <Aspose/Slides/Foss/presentation.h>

int main() {
    namespace asf = Aspose::Slides::Foss;

    asf::Presentation prs;
    auto& slide = prs.slides()[0];
    auto& main_shape = slide.shapes().add_auto_shape(
        asf::ShapeType::RECTANGLE, 50, 50, 600, 300);
    main_shape.text_frame()->set_text("Main slide content");

    // Create the notes slide and write text
    auto* notes = slide.notes_slide_manager().add_notes_slide();
    notes->notes_text_frame().set_text(
        "Mention the Q3 revenue increase. Emphasize the 24% YoY growth.");

    prs.save("with-notes.pptx", asf::SaveFormat::PPTX);
    return 0;
}

एकाधिक स्लाइड्स में नोट्स जोड़ें

#include <Aspose/Slides/Foss/presentation.h>
#include <vector>
#include <string>

int main() {
    namespace asf = Aspose::Slides::Foss;

    std::vector<std::string> note_texts = {
        "Opening: introduce the agenda and set expectations.",
        "Key metrics: emphasize Q4 results and growth trajectory.",
        "Closing: summarize and call to action.",
    };

    asf::Presentation prs;
    auto& layout = prs.slides()[0].layout_slide();
    prs.slides().add_empty_slide(layout);
    prs.slides().add_empty_slide(layout);

    for (size_t i = 0; i < prs.slides().size(); ++i) {
        auto& slide = prs.slides()[i];
        auto& slide_shape = slide.shapes().add_auto_shape(
            asf::ShapeType::RECTANGLE, 50, 50, 600, 300);
        slide_shape.text_frame()->set_text("Slide " + std::to_string(i + 1));

        auto* n = slide.notes_slide_manager().add_notes_slide();
        n->notes_text_frame().set_text(note_texts[i]);
    }

    prs.save("all-notes.pptx", asf::SaveFormat::PPTX);
    return 0;
}

नोट्स पहले से मौजूद हैं या नहीं जांचें

notes_slide_manager().notes_slide() यदि कोई नोट्स स्लाइड नहीं बनाई गई है तो null pointer लौटाता है:

#include <Aspose/Slides/Foss/presentation.h>
#include <iostream>

int main() {
    namespace asf = Aspose::Slides::Foss;

    asf::Presentation prs("existing.pptx");
    for (size_t i = 0; i < prs.slides().size(); ++i) {
        auto& slide = prs.slides()[i];
        auto* existing = slide.notes_slide_manager().notes_slide();
        if (existing) {
            std::cout << "Slide " << i + 1 << ": "
                      << existing->notes_text_frame().text().substr(0, 60) << "\n";
        } else {
            std::cout << "Slide " << i + 1 << ": no notes\n";
        }
    }
    return 0;
}

संबंधित देखें

 हिन्दी