Your First Aspose.Diagram Application - Hello World
Creating the Hello World Application
To create the Hello World application using Aspose.Diagram API:
- Cree una instancia de la clase Workbook.
- Aplicar la licencia:
- Si ha comprado una licencia, use la licencia en su aplicación para obtener acceso a la funcionalidad completa de Aspose.Diagram
- Si está utilizando la versión de evaluación del componente (si está utilizando Aspose.Diagram sin licencia), omita este paso.
- Cree un nuevo archivo Microsoft Visio o abra un archivo existente en el que desee agregar/actualizar algún texto.
- Inserta las palabrasHello World! en la página accedida.
- Genere el archivo Microsoft Visio modificado.
Los siguientes ejemplos demuestran los pasos anteriores.
Creando un Diagram
The following example creates a new diagram from scratch, writes the words “Hello World!” on the first page, and saves the file.
Crear nuevo archivo visio
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) |
Abrir un archivo existente
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) |