Aggiungere lo spazio dei nomi XML nei metadati XMP di EPS | .NET

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

Per aggiungere lo spazio dei nomi XML nei metadati XMP del file EPS, è necessario eseguire diversi passaggi:

  1. Inizializzare un flusso di input per il file EPS di input.
  2. Creare un’istanza di PsDocument dal flusso di input creato in precedenza.
  3. 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 un nuovo namespace XML ai metadati.
  4. Inizializza un flusso di output per il file EPS di output.
  5. Salva il file EPS con i metadati XMP modificati.

Il seguente frammento di codice mostra come aggiungere un namespace XML ai metadati XMP in un file EPS in C#:

 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_simple_props_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 new XML namespace "tmp".
17    xmp.RegisterNamespaceUri("tmp", "http://www.some.org/schema/tmp#");
18
19    // Add new string property in new namespace.
20    xmp.Add("tmp:newKey", new XmpValue("NewValue"));
21
22    // Save EPS file with changed XMP metadata
23
24    // Create ouput stream
25    using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "add_namespace_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
26    {
27        // Save EPS file
28        document.Save(outPsStream);
29    }
30
31}
32finally
33{
34    psStream.Close();
35}

Consulta l’aggiunta dello spazio dei nomi XML nei 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.