How to get Comment and Author from Visio FIle

Hello,

Team, we are trying to get comment added by author in visio, see sample snap shot for visio file.

Here I can get the comment using below code,
AnnotationCollection annotations = page.PageSheet.Annotations;

// Iterate through the annotations
foreach (Annotation annotation in annotations)
{
string comment = annotation.Comment.Value;
}

I want it to write in format like Author and Comment, if one author added multiple comments then Author write ones and then its comment .

How can i achieve this , please suggest.

Thanks

@Viral84

Based on your description, here is a likely technical approach for Aspose.Diagram.

You can read the author of a comment the same way you read the comment text – the Annotation object also exposes an Author cell.

// load the Visio document
Diagram diagram = new Diagram(@"C:\MyVisio.vsdx");

// collect author‑comment pairs (here we walk all pages)
var authorComments = new Dictionary<string, List<string>>();

foreach (Page page in diagram.Pages)
{
    foreach (Annotation ann in page.PageSheet.Annotations)
    {
        string author  = ann.Author?.Value ?? "Unknown";
        string comment = ann.Comment?.Value ?? string.Empty;

        if (!authorComments.ContainsKey(author))
            authorComments[author] = new List<string>();

        authorComments[author].Add(comment);
    }
}

// example output
foreach (var kvp in authorComments)
{
    Console.WriteLine($"Author: {kvp.Key}");
    foreach (string c in kvp.Value)
        Console.WriteLine($"  Comment: {c}");
}

The Annotation.Author cell gives you the name of the user who created the comment; you can then group the comments by that author as shown.

Clarifying questions

  1. Which version of Aspose.Diagram for .NET are you using (e.g., 23.x, 22.x, etc.)?
  2. Do you need the author‑comment list aggregated across the whole document, or separately for each page?

Hello,

I am using version 25.11.0.0 for aspose diagram and it do not have annotation.author.
see below class
namespace Aspose.Diagram
{
//
// Summary:
// Contains elements that contain information about comments inserted into a document
// page.
public class Annotation
{
//
// Summary:
// The shape ID of the comment.
public int ShapeID { get; set; }
//
// Summary:
// The zero-based index of the element within its parent element.
public int IX { get; set; }
//
// Summary:
// A flag indicating whether the element has been deleted locally. A value of 1
// indicates that the element was deleted locally.
public BOOL Del { get; set; }
//
// Summary:
// The x-coordinate of the comment marker in page coordinates.
public DoubleValue X { get; }
//
// Summary:
// The y-coordinate of the comment marker in page coordinates.
public DoubleValue Y { get; }
//
// Summary:
// Contains the ID number of the reviewer adding markup to the document.
public IntValue ReviewerID { get; }
//
// Summary:
// Specifies the index number assigned to a comment marker.
public IntValue MarkerIndex { get; }
//
// Summary:
// specifies when a comment was created
public DateValue Date { get; }
//
// Summary:
// Specifies when a comment was last changed
public DateValue EditDate { get; }
//
// Summary:
// Contains the comment text in string format for a shape.
public Str2Value Comment { get; }
//
// Summary:
// Indicates the locale ID (LCID) of the language in which the cell formula, text,
// custom property, or comment was entered.
public IntValue LangID { get; }
}
}
Thanks

@Viral84

Based on your description, here is a likely technical approach for Aspose.Diagram.

In version 25.11 the Annotation object does not expose an Author cell directly; the author is stored as a reviewer ID.
You can read the ReviewerID from the annotation and then look up the reviewer’s name in the diagram’s Reviewers collection (each reviewer has a Name property).

// load the Visio file
Diagram diagram = new Diagram(@"C:\MyVisio.vsdx");

// iterate pages and annotations
foreach (Page page in diagram.Pages)
{
    foreach (Annotation ann in page.PageSheet.Annotations)
    {
        // reviewer ID of the comment
        int revId = ann.ReviewerID.Value;

        // find the reviewer object (index is zero‑based)
        Reviewer reviewer = diagram.Reviewers[revId];

        string author  = reviewer?.Name?.Value ?? "Unknown";
        string comment = ann.Comment?.Value ?? string.Empty;

        Console.WriteLine($"Author: {author}");
        Console.WriteLine($"Comment: {comment}");
    }
}

This groups each comment with the name of the reviewer who created it.

Clarifying questions

  1. Does the Visio file contain reviewer entries (i.e., a non‑empty diagram.Reviewers collection)?
  2. Are you able to access the Reviewer class and its Name property in your project, or do you need the exact class/member names for that collection?

Thanks @Professionalize.Discourse

this works for me, only i have issue with get reviewer as it directly not exists,

I tried to get it using below code but , it seems it only works with index not based on provided reviewID value, so below line causing issue ,
Reviewer reviewer = diagram.DocumentSheet.Reviewers[revId];

@Viral84
Thanks for your inquiry.
Please try this sample code to get reviewer with reviewID:

 Reviewer viewer=  diagram.DocumentSheet.Reviewers.GetReviewer(reviewID);

Thanks.

Hello @philip.zhou

Thanks for update but diagram.DocumentSheet.Reviewers.GetReviewer here GetReiewer method also not exists in version 25.11

I finally updated code to Iterate all ReviewIndexID and match with revID.

Thanks

@Viral84
We have already added this method in version Aspose.Diagram v26.1.
Please update to version Aspose.Diagram v26.1 or Aspose.Diagram v26.2.
Thanks.