Aggiungere elementi array nei metadati XMP di EPS | .NET
Puoi verificare la qualità dei metadati XMP di Aspose.Page utilizzando l’app web Metadata
Per aggiungere elementi array nei metadati XMP di un file EPS, è necessario eseguire diversi passaggi:
- Inizializzare un flusso di input per il file EPS di input.
- Creare un’istanza di PsDocument dal flusso di input creato in precedenza.
- Ottenere un’istanza di XmpMetadata dal PsDocument. Se il file EPS specificato non contiene metadati XMP, ne verrà creato uno nuovo, compilato con i valori dei commenti dei metadati PS e restituito. 4. Ora puoi aggiungere elementi ai campi dei metadati dell’array.
- Inizializza un flusso di output per il file EPS di output.
- Salva il file EPS con i metadati XMP modificati.
Il seguente frammento di codice mostra come aggiungere elementi dell’array nei metadati XMP in un file EPS in C#:
1// Add array items in XMP metadata in EPS document.
2
3// Initialize EPS file input stream
4System.IO.FileStream psStream = new System.IO.FileStream(DataDir + "add_simple_props_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
5
6// Create PsDocument instance from stream
7PsDocument document = new PsDocument(psStream);
8
9string outputFileName = "add_xmp_array_items_out.eps";
10
11try
12{
13 // 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)
14 XmpMetadata xmp = document.GetXmpMetadata();
15
16 //Change XMP metadata values
17
18 // Add one more title. I will be added at the end of array by default.
19 xmp.AddArrayItem("dc:title", new XmpValue("NewTitle"));
20
21 // Add one more creator. It will be added in the array by an index (0).
22 xmp.AddArrayItem("dc:creator", 0, new XmpValue("NewCreator"));
23
24 // Save EPS file with changed XMP metadata
25
26 // Create ouput stream
27 using (System.IO.FileStream outPsStream = new System.IO.FileStream(OutputDir + outputFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
28 {
29 // Save EPS file
30 document.Save(outPsStream);
31 }
32}
33finally
34{
35 psStream.Close();
36}Valuta l’utilizzo dei metadati XMP online sulla nostra applicazione Metadata.
È possibile scaricare esempi e file di dati da GitHub.