XMP EPSメタデータ内の単純な値の変更 | .NET
Aspose.Page XMPメタデータの品質は、Metadata Webアプリで確認できます
EPSファイルのXMPメタデータ内の単純な値を変更するには、いくつかの手順を実行する必要があります。
- 入力EPSファイルの入力ストリームを初期化します。
- 事前に作成した入力ストリームから PsDocumentのインスタンスを作成します。
- PsDocumentから XmpMetadataのインスタンスを取得します。指定されたEPSファイルにXMPメタデータが含まれていない場合は、新しいメタデータが作成され、PSメタデータコメントの値が入力されて返されます。
- これで、メタデータフィールドの値を変更できます。
- 出力EPSファイル用の出力ストリームを初期化します。
- 変更した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_simple_values_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
17 // Change ModifyDate value
18 DateTime now = DateTime.UtcNow;
19 xmp["xmp:ModifyDate"] = now;
20
21 // Change Creator value
22 XmpValue value = new XmpValue("NewCreator");
23 xmp.Add("dc:creator", value);
24
25 // Change Title value
26 value = new XmpValue("NewTitle");
27 xmp.Add("dc:title", value);
28
29 // Save EPS file with changed XMP metadata
30
31 // Create ouput stream
32 using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "change_simple_values_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
33 {
34 // Save EPS file
35 document.Save(outPsStream);
36 }
37
38}
39finally
40{
41 psStream.Close();
42}
Metadata アプリケーションで、オンラインでXMPメタデータを評価します。
サンプルとデータ ファイルは GitHub からダウンロードできます。