XMP EPS Meta Verileriyle Çalışma

C# ile EPS dosyalarının meta verilerini ekleyin, düzenleyin ve alın

 

XMP meta verileri, dosyayı karakterize eden ve XML biçiminde temsil edilen bir dizi özelliktir. Dosyanın içeriğini açıklayan dosya bilgilerini ve bu dosyayı diğer dosyalardan ayırt etmeye olanak sağlayan kimlikleri içerir. Ayrıca, oluşturma ve değiştirme, dosyanın oluşturulmasında, değiştirilmesinde ve yüklenmesinde bir şekilde yer alan kullanıcılar ve dosyanın dönüşüm geçmişi hakkında verileri depolar.

Aspose.Page API çözümü, diğer farklı özellikler arasında EPS dosyalarının XMP metadatalarının çalışmasına izin verir. Burada nasıl ekleyeceğinizi, düzenleyeceğinizi ve alacağınızı açıklayan bilgileri bulacaksınız. XMP meta verileri . İşlevselliğin nasıl kullanılabileceğini görmek için XMP Meta Veri Düzenleyici web uygulamamızı da deneyin.

EPS dosyası C#'a XMP meta verileri ekleme adımları

  1. Belgeler dizininin yolunu ayarlayın.
  2. EPS dosyası giriş akışını başlatın.
  3. PsDocument Class kullanarak bir akıştan PS dosyası oluşturun.
  4. XMP meta verilerini almak için GetXmpMetadata() Yöntemini kullanın.
  5. Save() Yöntemini kullanarak değiştirilen EPS belgesini kaydedin.

XMP meta verileri 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();
    }

EPS dosyası C# olarak XMP meta verilerini düzenleme adımları

  1. Belgeler dizininin yolunu ayarlayın.
  2. EPS dosyası giriş akışını başlatın.
  3. PsDocument Sınıfını kullanarak bir akıştan bir PS dosyası oluşturun.
  4. XMP meta verilerini almak için GetXmpMetadata() Yöntemini kullanın.
  5. XMP meta veri değerlerini değiştirmek için SetArrayItem() Yöntemini kullanın.
  6. 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();
    }

EPS dosyasının C# XMP meta verilerini alma adımları

  1. Belgeler dizininin yolunu ayarlayın.
  2. EPS dosyası giriş akışını başlatın.
  3. PsDocument Sınıfını kullanarak bir akıştan bir PS dosyası oluşturun.
  4. 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 EPS Dosya Biçimi nedir

EPS (ERSF) veya Kapsüllenmiş PostScript Dosya Biçimi, aslında tek bir sayfanın nasıl görüneceğini tanımlayan bir PS programı olan biçimdir. Aslında, PostScript grafiklerini başka bir belgeye yerleştirmeye yardımcı olan sınırlı PS artı belirli notlardır. EPS, vektör grafiklerini veya birleştirilmiş vektör-raster grafiklerini mükemmel şekilde destekler. Biçimin özelliği, bir belgeye alınır alınmaz artık düzenlenememesidir. Bu biçimi, birlikte çalışabileceğiniz biçime dönüştürmenin nedenlerinden biri de budur.