इस ट्यूटोरियल में, हम सीखेंगे कि C++ का उपयोग करके DOCX में कमेंट कैसे डालें। Word दस्तावेज़ की समीक्षा के लिए टिप्पणियाँ उपयोगी हैं। वे दस्तावेज़ को स्वयं नहीं बदलते हैं, लेकिन लेखकों द्वारा Word दस्तावेज़ के किसी भी अनुभाग के बारे में चर्चा या टिप्पणी करने के लिए उपयोग किए जाते हैं।
C++ का उपयोग करके DOCX में टिप्पणी जोड़ने के चरण
- Aspose.Words.Cpp NuGet पैकेज इंस्टॉल करें
- Aspose::Words नाम स्थान का संदर्भ शामिल करें
- टिप्पणियां जोड़ने के लिए DOCX लोड करने के लिए Document Class का एक उदाहरण बनाएं
- C++ का उपयोग करके DOCX में टिप्पणी जोड़ने के लिए Comment Class ऑब्जेक्ट को तत्काल करें
- सेव मेथड का उपयोग करके वर्ड फाइल को कमेंट के साथ C++ में सेव करें
निम्नलिखित कोड में, हमने दिखाया है कि आप कितनी आसानी से Microsoft Word या Office Interop API पर निर्भरता के बिना C++ का उपयोग करके DOC फ़ाइल में टिप्पणियाँ शामिल कर सकते हैं। आप दस्तावेज़ को DOCX या DOC प्रारूप में सहेजने के लिए SaveFormat का उपयोग कर सकते हैं।
C++ का उपयोग करके DOCX में एक टिप्पणी जोड़ने के लिए कोड
#pragma once | |
#include <cstdint> | |
#include <iostream> | |
#include <Aspose.Words.Cpp/Body.h> | |
#include <Aspose.Words.Cpp/Comment.h> | |
#include <Aspose.Words.Cpp/CommentCollection.h> | |
#include <Aspose.Words.Cpp/CommentRangeEnd.h> | |
#include <Aspose.Words.Cpp/CommentRangeStart.h> | |
#include <Aspose.Words.Cpp/CompositeNode.h> | |
#include <Aspose.Words.Cpp/Document.h> | |
#include <Aspose.Words.Cpp/DocumentBuilder.h> | |
#include <Aspose.Words.Cpp/Node.h> | |
#include <Aspose.Words.Cpp/NodeCollection.h> | |
#include <Aspose.Words.Cpp/NodeType.h> | |
#include <Aspose.Words.Cpp/Paragraph.h> | |
#include <Aspose.Words.Cpp/ParagraphCollection.h> | |
#include <Aspose.Words.Cpp/Run.h> | |
#include <Aspose.Words.Cpp/RunCollection.h> | |
#include <Aspose.Words.Cpp/SaveFormat.h> | |
#include <Aspose.Words.Cpp/Saving/SaveOutputParameters.h> | |
#include <Aspose.Words.Cpp/Section.h> | |
#include <system/collections/list.h> | |
#include <system/convert.h> | |
#include <system/date_time.h> | |
#include <system/enumerator_adapter.h> | |
#include <system/exceptions.h> | |
using System::ArrayPtr; | |
using System::MakeArray; | |
using System::MakeObject; | |
using System::SharedPtr; | |
using System::String; | |
using namespace Aspose::Words; | |
class WorkingWithCommentsinCPP | |
{ | |
public: | |
void AddComments() | |
{ | |
// Create an instance of Document class of Aspose.Words for C++ | |
// to add a blank Word document | |
SharedPtr<Document> WordDocumentUsingCPP = MakeObject<Document>(); | |
// Instantiate DocumentBuilder class to add content to the Word Document | |
SharedPtr<DocumentBuilder> WordDocumentBuilder = MakeObject<DocumentBuilder>(WordDocumentUsingCPP); | |
// Add some text | |
WordDocumentBuilder->Write(u"Some text is added."); | |
// Add comment class object to add comment | |
SharedPtr<Comment> comment = MakeObject<Comment>(WordDocumentUsingCPP, u"Test Author", u"TA", | |
System::DateTime::get_Today()); | |
// Append comment to current paragraph of document | |
WordDocumentBuilder->get_CurrentParagraph()->AppendChild(comment); | |
// Add Comment | |
comment->get_Paragraphs()->Add(MakeObject<Paragraph>(WordDocumentUsingCPP)); | |
comment->get_FirstParagraph()->get_Runs()->Add(MakeObject<Run>(WordDocumentUsingCPP, u"Comment text.")); | |
// Save the word document with comments to docx format | |
WordDocumentUsingCPP->Save(u"WorkingWithComments.AddComments.docx"); | |
} | |
}; |
पिछले उदाहरण में, हमने C++ का उपयोग करके HTML को PDF में कैसे बदलें? देखा था। इस विषय में, हमने समझाया है कि कोड की कुछ पंक्तियों का उपयोग करके C++ का उपयोग करके DOCX में टिप्पणियों को कैसे सम्मिलित किया जाए।