Your First Aspose.Diagram Application - Hello World
Creating the Hello World Application
The steps below creates the Hello World application using the Aspose.Diagram API:
- Erstellen Sie eine Instanz derDiagram Klasse.
- Wenn Sie eine Lizenz haben, dannWende es an. Wenn Sie die Evaluierungsversion verwenden, überspringen Sie die lizenzbezogenen Codezeilen.
- Erstellen Sie eine neue Visio-Datei oder öffnen Sie eine vorhandene Visio-Datei.
- Erstellen Sie ein neues Textfeld.
- Füge die Wörter einHello World! in ein Textfeld.
- Generieren Sie die geänderte Datei Microsoft Visio.
Die Implementierung der obigen Schritte wird in den folgenden Beispielen demonstriert.
Codebeispiel: Erstellen einer neuen Diagram
The following example creates a new diagram from the scratch, writes Hello World! on the first page and saves the Visio file.
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_LoadSaveConvert(); | |
// Initialize a Diagram class | |
Diagram diagram = new Diagram(); | |
// Save diagram in the VSDX format | |
diagram.Save(dataDir + "CreateNewVisio_out.vsdx", SaveFileFormat.VSDX); |
Codebeispiel: Öffnen einer vorhandenen Datei
The following example opens an existing Microsoft Visio template file named “Sample.vsdx”, inputs “Hello World!” text in the first page and saves the diagram.
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_LoadSaveConvert(); | |
// Call the diagram constructor to load a VSD stream | |
FileStream st = new FileStream(dataDir + "Drawing1.vsdx", FileMode.Open); | |
Diagram vsdDiagram = new Diagram(st); | |
st.Close(); | |
// Call the diagram constructor to load a VDX diagram | |
Diagram vdxDiagram = new Diagram(dataDir + "Drawing1.vdx"); | |
/* | |
* Call diagram constructor to load a VSS stencil | |
* providing load file format | |
*/ | |
Diagram vssDiagram = new Diagram(dataDir + "Basic.vss", LoadFileFormat.VSS); | |
/* | |
* Call diagram constructor to load diagram from a VSX file | |
* providing load options | |
*/ | |
LoadOptions loadOptions = new LoadOptions(LoadFileFormat.VSX); | |
Diagram vsxDiagram = new Diagram(dataDir + "Drawing1.vsx", loadOptions); |