أول طلب Aspose.Diagram - Hello World
Contents
[
Hide
]
يوضح هذا البرنامج التعليمي كيفية إنشاء أول تطبيق (Hello World) باستخدام Aspose.Diagram “API البسيط. يقوم هذا التطبيق البسيط بإنشاء ملف Microsoft Visio بالنص” Hello World “في صفحة محددة.
إنشاء تطبيق Hello World
تؤدي الخطوات أدناه إلى إنشاء تطبيق Hello World باستخدام Aspose.Diagram API:
- قم بإنشاء مثيل لـDiagram صف دراسي.
- إذا كان لديك ترخيص ، إذنقم بتطبيقه. إذا كنت تستخدم الإصدار التقييمي ، فتخط سطور التعليمات البرمجية المتعلقة بالترخيص.
- قم بتكوين ملف Visio جديد ، أو افتح ملف Visio موجود.
- قم بإنشاء مربع نص جديد.
- أدخل الكلماتHello World! في مربع نص.
- قم بإنشاء ملف Microsoft Visio المعدل.
يتم توضيح تنفيذ الخطوات المذكورة أعلاه في الأمثلة أدناه.
نموذج التعليمات البرمجية: إنشاء Diagram جديد
المثال التالي ينشئ diagram جديد من الصفر ، يكتب Hello World! في الصفحة الأولى ويحفظ الملف Visio.
This file contains hidden or 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
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CreateNewVisio.class); | |
// initialize a Diagram class | |
Diagram diagram = new Diagram(); | |
// save diagram in the VSDX format | |
diagram.save(dataDir + "CreateNewVisio_Out.vsdx", SaveFileFormat.VSDX); |
نموذج التعليمات البرمجية: فتح ملف موجود
يفتح المثال التالي ملف قالب Microsoft Visio موجود باسم “Sample.vsdx” ، بإدخال “Hello World!” نص في الصفحة الأولى ويحفظ diagram.
This file contains hidden or 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
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReadVisioDiagram.class); | |
// Open the stream. Read only access is enough for Aspose.Diagram to load a diagram. | |
InputStream stream = new FileInputStream(dataDir + "Drawing1.vsdx"); | |
//Call the diagram constructor to load diagram from a VSDX stream | |
Diagram vsdDiagram = new Diagram(stream); | |
stream.close(); | |
//Call the diagram constructor to load diagram from a VDX file | |
Diagram vdxDiagram = new Diagram(dataDir + "Drawing1.vdx"); | |
/* | |
* Call diagram constructor to load diagram from a VSS file | |
* 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); |