Aspose Word to PDF - Show Comments with User & time

Hi Team ,
we are trying to convert the word files with comments to PDF. I could acheive the visibility of the comments in the docx to be printed in PDF by below code

doc.getLayoutOptions().setCommentDisplayMode(CommentDisplayMode.SHOW_IN_BALLOONS);

Which shows the comments in baloon like

But we need to show who made the comments and time as like how libreoffice shows like below.

Is there a way to achieve it.

@bharathikrishnaswamy

To display comments in a PDF with the author’s name and timestamp, similar to how LibreOffice presents them, you can customize the comment display settings in Aspose.Words. The default CommentDisplayMode.SHOW_IN_BALLOONS only shows the comments without additional details like the author and time.

Cause: The limitation arises because the default display mode does not include author and timestamp information.

Solution: To achieve your desired output, you will need to manually extract the comments from the document and format them accordingly before converting to PDF. Here’s a structured approach you can follow:

  1. Extract Comments: Loop through the comments in your Word document to get the author and timestamp.
  2. Format Comments: Create a custom layout for the comments that includes the author’s name and the date.
  3. Insert Comments into Document: You can insert these formatted comments into the document at the appropriate locations.
  4. Convert to PDF: Finally, save the document as a PDF.

Here’s a sample code snippet to get you started:

Document doc = new Document("input.docx");
for (Comment comment : doc.getChildNodes(NodeType.COMMENT, true)) {
    String author = comment.getAuthor();
    Date date = comment.getDateTime();
    String formattedComment = String.format("%s (%s): %s", author, date.toString(), comment.getText());
    
    // You can insert this formatted comment into the document as needed
    // For example, at the end of the document or in a specific location
}

// Save the document as PDF
doc.save("output.pdf");

This code will help you extract the comments and format them with the author’s name and timestamp. You can adjust the placement of the comments as per your requirements.

Next Steps: Implement the provided code in your project, customize the comment placement as needed, and run the conversion to PDF.

If you have any further questions or need additional assistance, feel free to ask!

@bharathikrishnaswamy Unfortunately, there is no way to achieve this. Aspose.Words renders comments the same way as MS Word does when document is printed or converted to PDF.