Your First Aspose.Diagram Application - Hello World

Creating the Hello World Application

To create the Hello World application using Aspose.Diagram API:

  1. Create an instance of the Workbook class.
  2. Apply the license:
    1. If you have purchased a license, then use the license in your application to get access to Aspose.Diagram' full functionality
    2. If you are using the evaluation version of the component (if you’re using Aspose.Diagram without a license), skip this step.
  3. Create a new Microsoft Visio file, or open an existing file in which you want to add/update some text.
  4. Insert the words Hello World! into the page accessed.
  5. Generate the modified Microsoft Visio file.

The examples below demonstrate the above steps.

Creating a Diagram

The following example creates a new diagram from scratch, writes the words “Hello World!” on the first page, and saves the file.

Create new visio file

todo:image_alt_text

import aspose.diagram
from aspose.diagram import *
#// Initialize a Diagram class
diagram = Diagram()
#// Save diagram in the VSDX format
diagram.save("CreateNewVisio_out.vsdx", SaveFileFormat.VSDX)

Opening an Existing File

The following example opens an existing Microsoft Visio template file, writes the words “Hello World!” in the first page, and saves the diagram as a new file.

import aspose.diagram
from aspose.diagram import *
diagram = Diagram(os.path.join(sourceDir, "Basic Shapes.vss"))
#// Add a new hello world rectangle shape
shapeId = diagram.add_shape(4.25, 5.5, 2, 1, "Rectangle", 0)
shape = diagram.pages[0].shapes.get_shape(shapeId)
shape.text.value.add(Txt("Hello World"))
#// Save diagram in the VSDX format
diagram.save("CreateHelloWorldVisio_out.vsdx", SaveFileFormat.VSDX)