XMP EPS Meta Verileri ile Çalışma
C# API ile EPS dosyalarının meta verilerini ekleyin, düzenleyin ve alın
XMP meta verileri, dosyayı karakterize eden ve XML formatında temsil edilen bir dizi özelliktir. Dosyanın içeriğini açıklayan dosya bilgilerini ve bu dosyanın diğer dosyalardan ayırt edilmesini sağlayan tanımlamaları içerir. Ayrıca oluşturma ve değiştirme verilerini, dosyanın oluşturulmasına, değiştirilmesine ve yüklenmesine bir şekilde katılan kullanıcıları ve dosya dönüştürme geçmişini depolar.
Aspose.Page API çözümü, diğer çeşitli özelliklerin yanı sıra EPS dosyalarının XMP meta verileriyle çalışmaya olanak tanır. Burada bunların nasıl ekleneceğini, düzenleneceğini ve alınacağını açıklayan bilgiler bulacaksınız. XMP meta verileri ile nasıl çalışılacağına dair daha fazla örnek inceleyin. Bu işlevselliğin nasıl kullanılabileceğini görmek için XMP Metadata Editor web uygulamamızı da deneyin.
C#'ta EPS Dosyasına XMP Meta Verisi Ekleme Adımları
- Belge dizini yolunu ayarlayın.
- Bir EPS dosyası giriş akışını başlatın.
- PsDocument Sınıfını kullanarak akıştan bir PS dosyası oluşturun.
- XMP meta verilerini almak için GetXmpMetadata() yöntemini kullanın.
- Değiştirilen EPS belgesini Save() yöntemini kullanarak kaydedin.
XMP meta verisi eklemek için C# kodu
using Aspose.Page.EPS;
using Aspose.Page.EPS.Device;
using Aspose.Page.EPS.XMP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; // The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithXMPMetadataInEPS();
// Initialize an EPS file input stream
System.IO.FileStream psStream = new System.IO.FileStream(dataDir + "add_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
// Create the PsDocument instance from the stream
PsDocument document = new PsDocument(psStream);
try
{
// Get XMP metadata. If the EPS file doesn't contain XMP metadata we get new one filled with values from PS metadata comments (%%Creator, %%CreateDate, %%Title etc)
XmpMetadata xmp = document.GetXmpMetadata();
// Check metadata values extracted from PS metadata comments and set up in new XMP metadata
// Get the "CreatorTool" value
if (xmp.Contains("xmp:CreatorTool"))
Console.WriteLine("CreatorTool: " + xmp["xmp:CreatorTool"].ToStringValue());
// Get the "CreateDate" value
if (xmp.Contains("xmp:CreateDate"))
Console.WriteLine("CreateDate: " + xmp["xmp:CreateDate"].ToStringValue());
// Get the "format" value
if (xmp.Contains("dc:format"))
Console.WriteLine("Format: " + xmp["dc:format"].ToStringValue());
// Get the "title" value
if (xmp.Contains("dc:title"))
Console.WriteLine("Title: " + xmp["dc:title"].ToArray()[0].ToStringValue());
// Get the "creator" value
if (xmp.Contains("dc:creator"))
Console.WriteLine("Creator: " + xmp["dc:creator"].ToArray()[0].ToStringValue());
// Get the "MetadataDate" value
if (xmp.Contains("xmp:MetadataDate"))
Console.WriteLine("MetadataDate: " + xmp["xmp:MetadataDate"].ToStringValue());
// Save the EPS file with new XMP metadata
// Create the ouput stream
using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "add_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
// Save the EPS file
document.Save(outPsStream);
}
}
finally
{
psStream.Close();
}C#'ta EPS Dosyasındaki XMP Meta Verilerini Düzenleme Adımları
- Belge dizini yolunu ayarlayın.
- Bir EPS dosyası giriş akışını başlatın.
- Akıştan PsDocument Sınıfını kullanarak bir PS dosyası oluşturun.
- XMP meta verilerini almak için GetXmpMetadata() yöntemini kullanın.
- XMP meta veri değerlerini değiştirmek için SetArrayItem() yöntemini kullanın.
- Değiştirilen EPS dosyasını kaydedin.
XMP meta verilerini değiştirmek için C# kodu
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithXMPMetadataInEPS();
// Initialize an EPS file input stream
System.IO.FileStream psStream = new System.IO.FileStream(dataDir + "add_simple_props_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
// Create a PsDocument instance from the stream
PsDocument document = new PsDocument(psStream);
try
{
// Get XMP metadata. If the EPS file doesn't contain XMP metadata we get new one filled with values from PS metadata comments (%%Creator, %%CreateDate, %%Title etc)
XmpMetadata xmp = document.GetXmpMetadata();
//Change the XMP metadata values
// Change the title item at index 0
xmp.SetArrayItem("dc:title", 0, new XmpValue("NewTitle"));
// Change the creator item at index 0
xmp.SetArrayItem("dc:creator", 0, new XmpValue("NewCreator"));
// Save the EPS file with the changed XMP metadata
// Create an ouput stream
using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "change_array_items_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
// Save the EPS file
document.Save(outPsStream);
}
}
finally
{
psStream.Close();
}C#'ta EPS Dosyasının XMP Meta Verilerini Alma Adımları
- Belge dizini yolunu ayarlayın.
- Bir EPS dosyası giriş akışını başlatın.
- Akıştan PsDocument Sınıfını kullanarak bir PS dosyası oluşturun.
- GetXmpMetadata() yöntemini kullanarak XMP meta verilerini alın.
XMP meta verilerini almak için C# kodu
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_WorkingWithXMPMetadataInEPS();
// Initialize an EPS file input stream
System.IO.FileStream psStream = new System.IO.FileStream(dataDir + "get_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
// Create a PsDocument instance from the stream
PsDocument document = new PsDocument(psStream);
try
{
// Get XMP metadata. If the EPS file doesn't contain XMP metadata we get new one filled with values from PS metadata comments (%%Creator, %%CreateDate, %%Title etc)
XmpMetadata xmp = document.GetXmpMetadata();
// Get the "CreatorTool" value
if (xmp.Contains("xmp:CreatorTool"))
Console.WriteLine("CreatorTool: " + xmp["xmp:CreatorTool"].ToStringValue());
// Get the "CreateDate" value
if (xmp.Contains("xmp:CreateDate"))
Console.WriteLine("CreateDate: " + xmp["xmp:CreateDate"].ToStringValue());
// Get a width of a thumbnail image if exists
if (xmp.Contains("xmp:Thumbnails") && xmp["xmp:Thumbnails"].IsArray)
{
XmpValue val = xmp["xmp:Thumbnails"].ToArray()[0];
if (val.IsNamedValues && val.ToDictionary().ContainsKey("xmpGImg:width"))
Console.WriteLine("Thumbnail Width: " + val.ToDictionary()["xmpGImg:width"].ToInteger());
}
// Get the "Format" value
if (xmp.Contains("dc:format"))
Console.WriteLine("Format: " + xmp["dc:format"].ToStringValue());
// Get the "DocumentID" value
if (xmp.Contains("xmpMM:DocumentID"))
Console.WriteLine("DocumentID: " + xmp["xmpMM:DocumentID"].ToStringValue());
}
finally
{
psStream.Close();
}SSS
1. XMP Meta Verisi nedir?
XMP, Genişletilebilir Meta Veri Platformu’nun kısaltmasıdır; medya dosyalarına meta veri özelliklerini gömmek için bir standarttır.
2. XMP’de hangi bilgiler bulunur?
Uygulamanın yazarı, editörü ve yaratıcısı hakkında sürüm, başlık, açıklama, anahtar kelimeler, dosyayı benzersiz bir şekilde tanımlamaya olanak tanıyan tanımlayıcılar ve geçmiş bilgileri ile birlikte bilgiler bulunmaktadır.
3. Bir EPS dosyasına XMP meta verileri nasıl eklenir?
Belgeler dizininin yolunu ayarlayın ve bir akıştan EPS dosyasını oluşturun. XMP meta verilerini eklemek için XmpMetadata Sınıfının Add() Yöntemlerini kullanın.
EPS What is EPS File Format
EPS (Encapsulated PostScript), tek sayfalık bir tasarımı tanımlayan PostScript tabanlı bir formattır. Vektör ve vektör‑raster birleşik grafikleri destekler. İçe aktarıldıktan sonra düzenlenemez; bu yüzden genellikle SVG veya PDF gibi düzenlenebilir bir formata dönüştürülür.