Manipolare i metadati XMP
Aggiungi, modifica e recupera facilmente metadati da file EPS, dandoti il controllo completo delle informazioni del tuo documento. Eleva il contenuto dei file EPS a un nuovo livello con la soluzione Aspose.Page per C++!
I metadati XMP sono una raccolta di proprietà per descrivere un file. È scritto in formato XML. I metadati includono informazioni sul contenuto del file, dettagli identificativi che lo differenziano da altri file e altri dati relativi alla creazione, modifica e cronologia dei caricamenti del file. Inoltre, registra i dettagli sugli utenti che hanno contribuito alla creazione, alla modifica e al caricamento del file.
Sblocca la potenza dei tuoi file EPS con la nostra soluzione API C++! Integrazione perfetta con i metadati XMP che ti dà il controllo completo sui tuoi documenti EPS. Che tu stia gestendo risorse digitali, migliorando le informazioni sul copyright o ottimizzando il flusso di lavoro creativo, la nostra API semplifica il processo, garantendo precisione ed efficienza. Migliora le tue capacità di gestione dei metadati e ottieni informazioni più approfondite sui tuoi file EPS. Sperimenta la perfetta integrazione con i metadati XMP utilizzando la nostra soluzione API C++. Acquista la soluzione oggi o ottieni semplicemente una prova gratuita per scoprire le funzionalità di aggiunta, modifica e recupero di metadati dai file EPS! Per ulteriori informazioni ed esempi sull’utilizzo dei metadati XMP, visitare la documentazione dell’API Aspose.Page su GitHub . Prova anche la nostra app Web XMP Metadata Editor per vedere come è possibile utilizzare la funzionalità.
Per eseguire l'esempio di codice avrai bisogno di:
Aspose.Page per l'API C++ che è un'API di manipolazione e conversione di documenti ricca di funzionalità, potente e facile da usare per la piattaforma C++.
Puoi scaricare direttamente la versione più recente, basta aprire il gestore pacchetti NuGet, cercare Aspose.Page.Cpp e installarlo. Puoi anche utilizzare il seguente comando dalla Console di gestione pacchetti.
Package Manager Console Command
PM> Install-Package Aspose.Page.Cpp
Aggiungi metadati XMP a un file EPS con C++
Per inserire metadati XMP in EPS sarà necessario utilizzare le entità della classe XmpMetadata . Esegui i passaggi successivi:
- Imposta il percorso della directory in cui si trova il documento.
- Inizializza un flusso di input per il file EPS.
- Utilizza la classe PsDocument per creare un file PS dal flusso di input.
- Recupera i metadati XMP chiamando il metodo GetXmpMetadata() . Se il file EPS non contiene metadati XMP, ne otteniamo uno nuovo pieno di valori dai commenti sui metadati PS.
- Salva il documento EPS modificato chiamando il metodo Save().
Aggiungi metadati XMP
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithXMPMetadataInEPS(); | |
// Initialize EPS file input stream | |
System::SharedPtr<System::IO::FileStream> psStream = System::MakeObject<System::IO::FileStream>(dataDir + u"add_input.eps", System::IO::FileMode::Open, System::IO::FileAccess::Read); | |
// Create PsDocument instance from stream | |
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(psStream); | |
{ | |
auto __finally_guard_0 = ::System::MakeScopeGuard([&psStream]() | |
{ | |
psStream->Close(); | |
}); | |
try | |
{ | |
// 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) | |
System::SharedPtr<XmpMetadata> xmp = document->GetXmpMetadata(); | |
// Check metadata values extracted from PS metadata comments and set up in new XMP metadata | |
// Get "CreatorTool" value | |
if (xmp->Contains(u"xmp:CreatorTool")) | |
{ | |
System::Console::WriteLine(System::String(u"CreatorTool: ") + xmp->idx_get(u"xmp:CreatorTool")->ToStringValue()); | |
} | |
// Get "CreateDate" value | |
if (xmp->Contains(u"xmp:CreateDate")) | |
{ | |
System::Console::WriteLine(System::String(u"CreateDate: ") + xmp->idx_get(u"xmp:CreateDate")->ToStringValue()); | |
} | |
// Get "format" value | |
if (xmp->Contains(u"dc:format")) | |
{ | |
System::Console::WriteLine(System::String(u"Format: ") + xmp->idx_get(u"dc:format")->ToStringValue()); | |
} | |
// Get "title" value | |
if (xmp->Contains(u"dc:title")) | |
{ | |
System::Console::WriteLine(System::String(u"Title: ") + xmp->idx_get(u"dc:title")->ToArray()->idx_get(0)->ToStringValue()); | |
} | |
// Get "creator" value | |
if (xmp->Contains(u"dc:creator")) | |
{ | |
System::Console::WriteLine(System::String(u"Creator: ") + xmp->idx_get(u"dc:creator")->ToArray()->idx_get(0)->ToStringValue()); | |
} | |
// Get "MetadataDate" value | |
if (xmp->Contains(u"xmp:MetadataDate")) | |
{ | |
System::Console::WriteLine(System::String(u"MetadataDate: ") + xmp->idx_get(u"xmp:MetadataDate")->ToStringValue()); | |
} | |
// Save EPS file with new XMP metadata | |
// Create ouput stream | |
{ | |
System::SharedPtr<System::IO::FileStream> outPsStream = System::MakeObject<System::IO::FileStream>(dataDir + u"output/" + u"add_output.eps", System::IO::FileMode::Create, System::IO::FileAccess::Write); | |
// Clearing resources under 'using' statement | |
System::Details::DisposeGuard<1> __dispose_guard_1({ outPsStream}); | |
// ------------------------------------------ | |
try | |
{ | |
// Save EPS file | |
document->Save(outPsStream); | |
} | |
catch(...) | |
{ | |
__dispose_guard_1.SetCurrentException(std::current_exception()); | |
} | |
} | |
} | |
catch (...) | |
{ | |
throw; | |
} | |
} |
Modifica i metadati XMP di un file EPS con C++
Per aggiungere elementi dell’array ai metadati XMP dovrai nuovamente utilizzare le stesse entità ed eseguire passaggi simili. Il passaggio aggiuntivo richiede l’utilizzo di SetArrayItem o AddArrayItem()
Modifica i metadati XMP
// The path to the documents directory. | |
System::String dataDir = RunExamples::GetDataDir_WorkingWithXMPMetadataInEPS(); | |
// Initialize EPS file input stream | |
System::SharedPtr<System::IO::FileStream> psStream = System::MakeObject<System::IO::FileStream>(dataDir + u"add_simple_props_input.eps", System::IO::FileMode::Open, System::IO::FileAccess::Read); | |
// Create PsDocument instance from stream | |
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(psStream); | |
{ | |
auto __finally_guard_0 = ::System::MakeScopeGuard([&psStream]() | |
{ | |
psStream->Close(); | |
}); | |
try | |
{ | |
// 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) | |
System::SharedPtr<XmpMetadata> xmp = document->GetXmpMetadata(); | |
//Change XMP metadata values | |
// Add one more title. I will be added at the end of array by default. | |
xmp->AddArrayItem(u"dc:title", System::MakeObject<XmpValue>(u"NewTitle")); | |
// Add one more creator. It will be added in the array by an index (0). | |
xmp->AddArrayItem(u"dc:creator", 0, System::MakeObject<XmpValue>(u"NewCreator")); | |
// Save EPS file with changed XMP metadata | |
// Create ouput stream | |
{ | |
System::SharedPtr<System::IO::FileStream> outPsStream = System::MakeObject<System::IO::FileStream>(dataDir + u"output/" + u"add_array_items_output.eps", System::IO::FileMode::Create, System::IO::FileAccess::Write); | |
// Clearing resources under 'using' statement | |
System::Details::DisposeGuard<1> __dispose_guard_1({ outPsStream}); | |
// ------------------------------------------ | |
try | |
{ | |
// Save EPS file | |
document->Save(outPsStream); | |
} | |
catch(...) | |
{ | |
__dispose_guard_1.SetCurrentException(std::current_exception()); | |
} | |
} | |
} | |
catch (...) | |
{ | |
throw; | |
} | |
} |
EPS Cos'è il formato file EPS
EPS (ERSF) o Encapsulated PostScript File Format è il formato che è in realtà un programma PS che descrive l'aspetto di una singola pagina. In realtà è un PS limitato più note particolari che aiutano a incapsulare la grafica PostScript in un altro documento. EPS supporta perfettamente la grafica vettoriale o la grafica raster vettoriale combinata. La particolarità del formato è che non appena viene importato in un documento, non può più essere modificato. Questo è uno dei motivi per convertire questo formato in quello con cui puoi lavorare.