Microsoftを介してMicrosoft>® Visioファイルメタデータを管理する
サーバー側のJavaAPIを使用して、組み込みおよびカスタムのVisioファイルのプロパティを表示、追加、更新、削除、または抽出します。
Java Visio API タイトル、作成者名、ドキュメント統計などのシステム定義(組み込み)プロパティ、および名前と値のペアの形式でのユーザー定義(カスタム)プロパティの管理をサポートします。がある Diagramクラス ファイルをロードし、 PageCollection ページのコレクションだけでなく ページクラス 単一のページを表すため。これらのクラス、documentproperties、custompropsに加えて、メタデータ管理のプロセスが簡単になります。
組み込みプロパティの管理
システム定義のプロパティを管理するために、APIは documentproperties 、およびプログラマーは、組み込みのプロパティに簡単にアクセスして、その値を更新できます。
Javaビルトインプロパティを管理するためのコード
// 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(AutoFitShapesInVisio.class); | |
// load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "BFlowcht.vsdx"); | |
//// Display Visio version and document modification time at different stages | |
System.out.println(diagram.getVersion()); | |
System.out.println(diagram.getDocumentProps().getBuildNumberCreated()); | |
System.out.println(diagram.getDocumentProps().getBuildNumberEdited()); | |
System.out.println(diagram.getDocumentProps().getTimeCreated()); | |
System.out.println(diagram.getDocumentProps().getTimeEdited()); | |
System.out.println(diagram.getDocumentProps().getTimePrinted()); | |
System.out.println(diagram.getDocumentProps().getTimeSaved()); | |
System.out.println(diagram.getDocumentProps().getCustomProps().getCount()); |
カスタム定義プロパティの管理
ユーザー定義のプロパティを管理するために、APIは customprops 、および開発者は、すでに追加されているプロパティに簡単にアクセスしたり、新しいプロパティを追加したりできます。カスタムプロパティを追加するには、 [メソッドを追加]( https://apireference.aspose.com/diagram/java/com.aspose.diagram/custompropcollection#add(com.aspose.diagram.CustomProp) )プロパティを追加し、新しいプロパティの参照をとして返します CustomProp 物体。 CustomPropクラスは、ドキュメントプロパティの名前、値、およびタイプを次のように取得するために使用されます。 名前 、 customvalue 、 プロパティタイプ 列挙値。
JavaVisioファイルにメタデータを追加するコード
// 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(AutoFitShapesInVisio.class); | |
// Load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//// Get CustomProperties of diagram | |
CustomPropCollection customProperties = diagram.getDocumentProps().getCustomProps(); | |
//Set property of CustomProp | |
CustomProp customProp = new CustomProp(); | |
customProp.setPropType(PropType.STRING); | |
customProp.getCustomValue().setValueString ("Test"); | |
//Add CustomProp to Collection | |
customProperties.add(customProp); |
JavaVisioファイルのプロパティを削除するコード
// 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(AutoFitShapesInVisio.class); | |
// Load a Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
//// Get CustomProperties of diagram | |
CustomPropCollection customProperties = diagram.getDocumentProps().getCustomProps(); | |
//Remove CustomProp | |
for (int i = 0; i < customProperties.getCount(); i++) | |
{ | |
CustomProp customProp = customProperties.get(i); | |
if (customProp.getName()== "Test") | |
{ | |
customProperties.remove(customProp); | |
} | |
} |