Your First Aspose.Diagram Application - Hello World
Creating the Hello World Application
To create the Hello World application using Aspose.Diagram API:
- Create an instance of the Workbook class.
- Apply the license:
- If you have purchased a license, then use the license in your application to get access to Aspose.Diagram' full functionality
- If you are using the evaluation version of the component (if you’re using Aspose.Diagram without a license), skip this step.
- Create a new Microsoft Visio file, or open an existing file in which you want to add/update some text.
- Insert the words Hello World! into the page accessed.
- 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
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) |