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 + "add_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    // Add named value to "xmpTPg:MaxPageSize" structure.
17    xmp.AddNamedValue("xmpTPg:MaxPageSize", "stDim:newKey", new XmpValue("NewValue"));
18
19    // Save EPS file with changed XMP metadata
20
21    // Create ouput stream
22    using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "add_named_value_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
23    {
24        // Save EPS file
25        document.Save(outPsStream);
26    }
27
28}
29finally
30{
31    psStream.Close();
32}

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.