जावा का उपयोग करके वर्ड में टिप्पणियाँ कैसे जोड़ें

यह सरल ट्यूटोरियल ** जावा का उपयोग करके वर्ड में टिप्पणियों को कैसे जोड़ें ** पर संक्षिप्त करता है। आप Word फ़ाइल के लिए उपलब्ध टिप्पणियों के विभिन्न उन्नत गुण सेट कर सकते हैं और फ़ाइल को फिर से DOCX के रूप में सहेज सकते हैं। यहाँ जावा का उपयोग करके वर्ड में टिप्पणी कैसे सम्मिलित करें के चरण दिए गए हैं।

Java का उपयोग करके Word में टिप्पणियाँ जोड़ने के चरण

  1. टिप्पणियाँ सम्मिलित करने के लिए मावेन रिपॉजिटरी से Aspose.Words जोड़ें
  2. Document क्लास ऑब्जेक्ट का उपयोग करके सोर्स वर्ड फ़ाइल खोलें
  3. कर्सर को लक्ष्य अनुच्छेद पर ले जाएँ
  4. जावा का उपयोग करते हुए वर्ड डॉक्यूमेंट पैराग्राफ में कमेंट डालें
  5. टिप्पणियाँ जोड़ने के बाद फ़ाइल को सहेजें

इन चरणों का उपयोग करके हम एक Word दस्तावेज़ खोलते हैं और DocumentBuilder ऑब्जेक्ट को इनिशियलाइज़ करते हैं जिसका उपयोग Word फ़ाइल के विभिन्न तत्वों जैसे इसके पैराग्राफ तक पहुँचने के लिए किया जा सकता है। हम कर्सर को किसी भी तत्व पर ले जा सकते हैं जो एमएस वर्ड में मैन्युअल रूप से कर्सर की गति की नकल करता है। अंत में हम टिप्पणियाँ जोड़ते हैं और Word फ़ाइल को सहेजते हैं।

जावा का उपयोग करके Word दस्तावेज़ में टिप्पणियाँ जोड़ने के लिए कोड

import com.aspose.words.License;
import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.Comment;
import com.aspose.words.Paragraph;
import com.aspose.words.Run;
import java.util.Date;
public class HowToAddCommentsInWordUsingJava
{
public static void main(String[] args) throws Exception { //main function for AddImageInWord class
// Initialize a license to avoid trial version watermark in the output Word file after adding image
License license = new License();
license.setLicense("Aspose.Words.lic");
// Load the Word document where comments are to be added
Document DocumentForComment = new Document("input.docx");
DocumentBuilder builder = new DocumentBuilder(DocumentForComment);
// Move the cursor to the beginning of the document for adding comments
builder.moveToDocumentStart();
// Insert comment to first paragraph of document by providing Author, Initial, time and comment text
Comment comment = new Comment(DocumentForComment, "Aspose.Words", "AW", new Date());
builder.getCurrentParagraph().appendChild(comment);
comment.getParagraphs().add(new Paragraph(DocumentForComment));
comment.getFirstParagraph().getRuns().add(new Run(DocumentForComment, "Comment text."));
// Save the Document with comments
DocumentForComment.save("OutputDocumentWithComments.docx");
}
}

इस जावा कोड में, हमने कमेंट क्लास ऑब्जेक्ट का उपयोग किया है जिसमें वर्ड दस्तावेज़ में एक टिप्पणी को कॉन्फ़िगर करने के लिए आवश्यक सभी गुण शामिल हैं। हम लेखक का नाम, उपयोगकर्ता का नाम, टिप्पणियों का समय प्रदान करते हैं और फिर अंत में टिप्पणियों का टेक्स्ट सेट करते हैं।

इस चरण-दर-चरण ट्यूटोरियल में, हमने एक मौजूदा फ़ाइल खोली और उसमें टिप्पणियाँ जोड़ीं। यदि आप तालिका में पंक्ति जोड़ने जैसी अधिक सुविधाओं के बारे में जानना चाहते हैं, तो जावा का उपयोग करके वर्ड में तालिका में एक पंक्ति कैसे जोड़ें? पर लेख देखें। ध्यान दें कि उपरोक्त कोड को चलाने के लिए सिस्टम पर किसी एमएस वर्ड या इंटरऑप की आवश्यकता नहीं है।

 हिन्दी