EPSファイルのXMPメタデータ内の名前付き値の変更|.NET

Aspose.Page XMPメタデータの品質は、Metadata Webアプリで確認できます

EPSファイルのXMPメタデータ内の名前付き値を変更するには、以下の手順を実行する必要があります。

  1. 入力EPSファイルの入力ストリームを初期化します。
  2. 先ほど作成した入力ストリームから PsDocumentのインスタンスを作成します。
  3. PsDocumentから XmpMetadataのインスタンスを取得します。指定したEPSファイルにXMPメタデータが含まれていない場合は、新しいメタデータが作成され、PSメタデータコメントの値が入力されて返されます。
  4. これで、構造化メタデータフィールドの名前付き値を変更できます。
  5. 出力EPSファイル用の出力ストリームを初期化します。
  6. 変更されたXMPメタデータを含むEPSファイルを保存します。

次のコードスニペットは、C#でEPSファイルのXMPメタデータの名前付き値を変更する方法を示しています。

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithXMPMetadataInEPS();
 4// Initialize EPS file input stream
 5System.IO.FileStream psStream = new System.IO.FileStream(dataDir + "change_named_value_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
 6// Create PsDocument instance from stream
 7PsDocument document = new PsDocument(psStream);            
 8
 9try
10{
11    // Get XMP metadata. If EPS file doesn't contain XMP metadata we get new one filled with values from PS metadata comments (%%Creator, %%CreateDate, %%Title etc)
12    XmpMetadata xmp = document.GetXmpMetadata();
13
14    //Change XMP metadata values
15
16    // Change named value "stDim:unit" in "xmpTPg:MaxPageSize" structure.
17    xmp.SetNamedValue("xmpTPg:MaxPageSize", "stDim:unit", new XmpValue("Inches"));
18
19    // Add named value "stDim:newKey" in "xmpTPg:MaxPageSize" structure.
20    xmp.SetNamedValue("xmpTPg:MaxPageSize", "stDim:newKey", new XmpValue("NewValue"));
21
22    // Save EPS file with changed XMP metadata
23
24    // Create ouput stream
25    using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "change_named_value_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
26    {
27        // Save EPS file
28        document.Save(outPsStream);
29    }
30
31}
32finally
33{
34    psStream.Close();
35}

XMPメタデータ内の名前付き値の変更については、 Java および C++ を参照してください。

Metadata アプリケーションで、オンラインでXMPメタデータを評価します。

サンプルとデータ ファイルは GitHub からダウンロードできます。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.