Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active November 26, 2021 16:20

Revisions

  1. aspose-com-kb revised this gist Nov 26, 2021. No changes.
  2. aspose-com-kb revised this gist Nov 25, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion How to Add Comments in Word using Java.java
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,6 @@ public static void main(String[] args) throws Exception { //main function for Ad
    comment.getFirstParagraph().getRuns().add(new Run(DocumentForComment, "Comment text."));

    // Save the Document with comments
    DocumentForComment.save("output.docx");
    DocumentForComment.save("OutputDocumentWithComments.docx");
    }
    }
  3. aspose-com-kb revised this gist Nov 25, 2021. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions How to Add Comments in Word using Java.java
    Original file line number Diff line number Diff line change
    @@ -11,24 +11,24 @@ 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");
    // 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);
    // 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();
    // 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."));
    // 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("output.docx");
    }
    // Save the Document with comments
    DocumentForComment.save("output.docx");
    }
    }
  4. aspose-com-kb revised this gist Nov 25, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion How to Add Comments in Word using Java.java
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@

    public class HowToAddCommentsInWordUsingJava
    {
    public static void main(String[] args) throws Exception { //main function for AddImageInWord class
    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();
  5. aspose-com-kb revised this gist Nov 25, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions How to Add Comments in Word using Java.java
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,9 @@ 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");
    // 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");
  6. aspose-com-kb created this gist Nov 25, 2021.
    34 changes: 34 additions & 0 deletions How to Add Comments in Word using Java.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    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("output.docx");
    }
    }