How to Add Comments to Visio Drawings in C#.

This step by step tutorial shows you how to add comments to Visio drawings in C#. You can easily add comments to Visio drawings in C# with few lines of code. The comments are helpful hints in the Visio files which can be attached to a page or a shape etc.

Steps to Add Comments to Visio Drawings in C#

  1. Setup Aspose.Diagram for .NET from NuGet.org
  2. Add reference to Aspose.Diagram namespace
  3. Specify license with the help of SetLicense method
  4. Load the input Visio file using Diagram class
  5. Add comment to the first page of the Visio file using AddComment method
  6. Save the output Visio file with the comment added using Save method

As you can notice from the above steps, adding comments to Visio diagrams in C# is easy. The comments can be attached to the Visio diagrams in any type of .NET applications be it web, desktop or other type of applications.

Code to Add Comments to Visio Drawings in C#

using System;
//Use following namespace to add comment in Visio diagram
using Aspose.Diagram;
namespace AddCommentToVisioDiagram
{
class Program
{
static void Main(string[] args)
{
//Set license before adding comment in visio diagram
Aspose.Diagram.License AsposeDiagramLicense = new Aspose.Diagram.License();
AsposeDiagramLicense.SetLicense(@"c:\asposelicense\license.lic");
//Load visio diagram file
Diagram VisioDiagram = new Diagram("InputVisioDiagram.vsx");
//add comment to the input visio diagram
VisioDiagram.Pages[0].AddComment(8.0, 4.0, "Sample comment");
//save output visio diagram with the comment added
VisioDiagram.Save("Output_Visio_Diagram_with_Comment.vsx", SaveFileFormat.Vsx);
}
}
}

The above code makes it clear how to add comment in Visio diagram in your C# applications. Earlier, we saw the code to convert VSX to HTML in C#. However, in this case, we’re loading a VSX and then saving it to the same VSX format after adding comment to the Visio file.

 English