Your First Aspose.Diagram Application - Hello World
Contents
[
Hide
]
This tutorial shows how to create a very first application (Hello World) using Aspose.Diagram' simple API. This simple application creates a Microsoft Visio file with the text ‘Hello World’ in a specified Page.
Creating the Hello World Application
The steps below creates the Hello World application using the Aspose.Diagram API:
- Cree una instancia de la clase Diagram.
- 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 Visio o abra un archivo Visio existente.
- Crear un nuevo cuadro de texto.
- Inserta las palabrasHello World! en un cuadro de texto.
- Genere el archivo Microsoft Visio modificado.
La implementación de los pasos anteriores se demuestra en los siguientes ejemplos.
Code Sample: Creating a New Diagram and Writing Hello World!
El siguiente ejemplo abre un archivo de plantilla Microsoft Visio existente llamado “Basic_Shapes.vss”, inputs “Hello World!” text in the first page and saves the diagram.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jpype | |
import asposediagram | |
jpype.startJVM() | |
from asposediagram.api import * | |
lic = License() | |
lic.setLicense("Aspose.Total.Product.Family.lic") | |
diagram = Diagram("Basic_Shapes.vss") | |
# Add a new hello world rectangle shape | |
shapeId = diagram.addShape(4.25, 5.5, 2, 1, "Rectangle", 0) | |
shape = diagram.getPages().getPage(0).getShapes().getShape(shapeId) | |
shape.getText().getValue().add(Txt("Hello World")) | |
# Save diagram in the VSDX format | |
diagram.save("CreateHelloWorldVisio_out.vsdx", SaveFileFormat.VSDX) | |
jpype.shutdownJVM() |