管理文档属性
介绍
Microsoft Visio 提供向 visio 文件添加属性的功能。这些文档属性提供了有用的信息,分为 2 个类别,详述如下。
- 系统定义(内置)属性:内置属性包含有关文档的一般信息,如文档标题、作者姓名、文档统计信息等。
- 用户定义(自定义)属性:最终用户以名称-值对的形式定义的自定义属性。
使用 Microsoft Visio 管理文档属性
Microsoft Visio 允许您以所见即所得的方式管理Visio文件的文档属性。请按照以下步骤打开特性Visio 2016 中的对话框。
- 来自文件菜单,选择信息.
选择信息菜单 |
---|
![]() |
- 点击特性标题并选择“高级属性”。
单击高级属性选择 |
---|
![]() |
- 管理文件的文档属性。
属性对话框 |
---|
![]() |
在 Properties 对话框中,有不同的选项卡,如 General、Summary、Statistics、Contents 和 Customs。每个选项卡都有助于配置与文件相关的不同类型的信息。自定义选项卡用于管理自定义属性。 |
使用 Aspose.Diagram 处理文档属性
开发人员可以使用 Aspose.Diagram API 动态管理文档属性。此功能可帮助开发人员将有用的信息与文件一起存储,例如文件的接收、处理时间、时间戳等。
Aspose.Diagram for .NET 直接在输出文件中写入API和Version Number的信息。
请注意,您不能指示 Aspose.Diagram for .NET 更改或从输出文档中删除此信息。
访问文档属性
Aspose.Diagram API 支持两种类型的文档属性,内置的和自定义的。 Aspose.Diagram'Diagram class 代表一个 Visio 文件,和 visio 文件一样,Diagram类可以包含多个页面,每个页面由页类,而页面集合由页面集合班级。
使用Diagram访问文件的文档属性,如下所述。
- 要访问内置文档属性,请使用diagram.DocumentProps.
- 要访问自定义文档属性,请使用diagram.DocumentProps.CustomProps.
// 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_Shapes(); | |
// Load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//// Display Visio version and document modification time at different stages | |
Console.WriteLine("Visio Instance Version : " + diagram.Version); | |
Console.WriteLine("Full Build Number Created : " + diagram.DocumentProps.BuildNumberCreated); | |
Console.WriteLine("Full Build Number Edited : " + diagram.DocumentProps.BuildNumberEdited); | |
Console.WriteLine("Date Created : " + diagram.DocumentProps.TimeCreated); | |
Console.WriteLine("Date Last Edited : " + diagram.DocumentProps.TimeEdited); | |
Console.WriteLine("Date Last Printed : " + diagram.DocumentProps.TimePrinted); | |
Console.WriteLine("Date Last Saved : " + diagram.DocumentProps.TimeSaved); | |
Console.WriteLine("CustomProps Length " + diagram.DocumentProps.CustomProps.Count); |
添加或删除自定义文档属性
正如我们之前在本主题开头所述,开发人员无法添加或删除内置属性,因为这些属性是系统定义的,但可以添加或删除自定义属性,因为它们是用户定义的。
添加自定义属性
Aspose.Diagram API暴露了添加的方法自定义道具集合类以便将自定义属性添加到集合中。
// 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_Shapes(); | |
// Load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//// Get CustomProperties of diagram | |
Aspose.Diagram.CustomPropCollection customProperties = diagram.DocumentProps.CustomProps; | |
//Set property of CustomProp | |
Aspose.Diagram.CustomProp customProp = new Aspose.Diagram.CustomProp(); | |
customProp.PropType = Aspose.Diagram.PropType.String; | |
customProp.CustomValue.ValueString = "Test"; | |
//Add CustomProp to Collection | |
customProperties.Add(customProp); |
删除自定义属性
要使用 Aspose.Diagram 删除自定义属性,请调用CustomPropCollection.Remove方法并传递要删除的文档属性的名称。