Ottieni metadati XMP da file EPS utilizzando .NET

Puoi verificare la qualità dei metadati XMP di Aspose.Page utilizzando l’app web Metadata.

Per estrarre i metadati XMP dal file EPS, è necessario eseguire diversi passaggi:

  1. Aprire un FileStream (o un’istruzione using) per il file EPS, ad esempio using var stream = new FileStream("sample.eps", FileMode.Open);.
  2. Creare un PsDocument dallo stream: var document = new PsDocument(stream);.
  3. Recuperare i metadati XMP tramite XmpMetadata xmp = document.XmpMetadata;. Se l’EPS non contiene XMP, Aspose crea un nuovo oggetto XmpMetadata popolato dai commenti PS.
  4. Accedere alle proprietà dei metadati come xmp.Title, xmp.Author, xmp.Description per leggere i valori.

Il seguente frammento di codice mostra come estrarre i metadati XMP da un file EPS in C#:

 1// Get XMP metadata from EPS document.
 2
 3// Create PsDocument instance from file
 4PsDocument document = new PsDocument(DataDir + "get_input.eps");
 5
 6// 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)
 7XmpMetadata xmp = document.GetXmpMetadata();
 8
 9// Get "CreatorTool" value
10if (xmp.Contains("xmp:CreatorTool"))
11    Console.WriteLine("CreatorTool: " + xmp["xmp:CreatorTool"].ToStringValue());
12
13// Get "CreateDate" value
14if (xmp.Contains("xmp:CreateDate"))
15    Console.WriteLine("CreateDate: " + xmp["xmp:CreateDate"].ToStringValue());
16
17// Get a width of a thumbnail image if exists
18if (xmp.Contains("xmp:Thumbnails") && xmp["xmp:Thumbnails"].IsArray)
19{
20    XmpValue val = xmp["xmp:Thumbnails"].ToArray()[0];
21    if (val.IsNamedValues && val.ToDictionary().ContainsKey("xmpGImg:width"))
22        Console.WriteLine($"Thumbnail Width: {val.ToDictionary()["xmpGImg:width"].ToInteger()}");
23}
24
25// Get "format" value
26if (xmp.Contains("dc:format"))
27    Console.WriteLine("Format: " + xmp["dc:format"].ToStringValue());
28
29// Get "DocumentID" value
30if (xmp.Contains("xmpMM:DocumentID"))
31    Console.WriteLine("DocumentID: " + xmp["xmpMM:DocumentID"].ToStringValue());

Consulta l’estrazione dei metadati XMP in Java e C++.

Valuta l’utilizzo dei metadati XMP online sulla nostra applicazione Metadata.

È possibile scaricare esempi e file di dati da GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.