Agregue metadatos XMP a un archivo EPS usando .NET
Puede comprobar la calidad de los metadatos XMP de Aspose.Page trabajando con la aplicación web Metadata
Para agregar metadatos XMP a un archivo EPS es necesario seguir varios pasos:
- Inicialice un flujo de entrada para el archivo EPS de entrada.
 - Cree una instancia de PsDocument a partir del flujo de entrada creado anteriormente.
 - Obtenga una instancia de XmpMetadata del PsDocument. Si el archivo EPS dado no contiene metadatos XMP, el nuevo se creará, se completará con valores de los comentarios de metadatos de PS y se le devolverá.
 - Ahora puedes ver los valores de los campos de metadatos.
 - Inicialice un flujo de salida para el archivo EPS de salida.
 - Guarde el archivo EPS con nuevos metadatos XMP.
 
El siguiente fragmento de código muestra cómo agregar metadatos XMP a un archivo EPS en C#:
 1// Add XMP metadata to EPS document.
 2
 3// Initialize EPS file input stream
 4System.IO.FileStream psStream = new System.IO.FileStream(DataDir + "add_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
 5
 6// Create PsDocument instance from stream. Given EPS file doesn't contain XMP metadata, but usual metadata does contain.
 7PsDocument document = new PsDocument(psStream);
 8
 9string outputFileName = "add_xmp_metadata_out.eps";
10
11XmpMetadata xmp = null;            
12
13try
14{
15    // 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)
16    xmp = document.GetXmpMetadata();
17
18    // Check metadata values extracted from PS metadata comments and set up in new XMP metadata
19
20    // Get "CreatorTool" value
21    if (xmp.Contains("xmp:CreatorTool"))
22        Console.WriteLine("CreatorTool: " + xmp["xmp:CreatorTool"].ToStringValue());
23
24    // Get "CreateDate" value
25    if (xmp.Contains("xmp:CreateDate"))
26        Console.WriteLine("CreateDate: " + xmp["xmp:CreateDate"].ToStringValue());
27
28    // Get "format" value
29    if (xmp.Contains("dc:format"))
30        Console.WriteLine("Format: " + xmp["dc:format"].ToStringValue());
31
32    // Get "title" value
33    if (xmp.Contains("dc:title"))
34        Console.WriteLine("Title: " + xmp["dc:title"].ToArray()[0].ToStringValue());
35
36    // Get "creator" value
37    if (xmp.Contains("dc:creator"))
38        Console.WriteLine("Creator: " + xmp["dc:creator"].ToArray()[0].ToStringValue());
39
40    // Get "MetadataDate" value
41    if (xmp.Contains("xmp:MetadataDate"))
42        Console.WriteLine("MetadataDate: " + xmp["xmp:MetadataDate"].ToStringValue());
43
44    // Update MetadataDate value                
45    DateTime metadataDate = xmp["xmp:MetadataDate"].ToDateTime();
46
47    // Save EPS file with new XMP metadata
48
49    // Create ouput stream
50    using (System.IO.FileStream outPsStream = new System.IO.FileStream(OutputDir + outputFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
51    {
52        // Save EPS file
53        document.Save(outPsStream);
54    }
55}
56finally
57{
58    psStream.Close();
59}Evalúe los metadatos XMP trabajando en línea en nuestra aplicación Metadatos.
Puede descargar ejemplos y archivos de datos desde GitHub.