Your First Aspose.Diagram Application - Hello World
Creating the Hello World Application
To create the Hello World application using Aspose.Diagram API:
- Creare un’istanza della classe Workbook.
- Applica la licenza:
- Se hai acquistato una licenza, usa la licenza nella tua applicazione per ottenere l’accesso alla piena funzionalità di Aspose.Diagram
- Se stai utilizzando la versione di valutazione del componente (se stai utilizzando Aspose.Diagram senza licenza), salta questo passaggio.
- Crea un nuovo file Microsoft Visio o apri un file esistente in cui desideri aggiungere/aggiornare del testo.
- Inserisci le paroleHello World! nella pagina a cui si accede.
- Generare il file Microsoft Visio modificato.
Gli esempi seguenti illustrano i passaggi precedenti.
Creazione di un numero Diagram
The following example creates a new diagram from scratch, writes the words “Hello World!” on the first page, and saves the file.
Crea un nuovo file 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) |
Apertura di un file esistente
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) |