XMP EPS 메타데이터 작업

C#으로 EPS 파일의 메타데이터 추가, 편집 및 가져오기

 

XMP 메타데이터는 파일을 특성화하고 XML 형식으로 표시되는 속성 집합입니다. 여기에는 파일의 내용을 설명하는 파일 정보와 이 파일을 다른 파일과 구별할 수 있는 식별 정보가 포함됩니다. 또한 생성 및 수정, 파일 생성, 변경 및 업로드에 어떤 식으로든 참여한 사용자, 파일 변형 이력에 대한 데이터를 저장합니다.

다른 기능 중 Aspose.Page API 솔루션을 사용하면 EPS 파일의 XMP 메타데이터를 사용할 수 있습니다. 여기에서 추가, 편집 및 가져오는 방법을 설명하는 정보를 찾을 수 있습니다. [XMP 메타데이터]( https://github.com/aspose-page/Aspose.Page-for-.NET/tree/master/Examples/Aspose.Page.Examples.CSharp/ XMPMetadataInEPS로 작업). 또한 XMP Metadata Editor 웹 앱을 사용하여 기능이 어떻게 사용되는지 확인하십시오.

EPS 파일 C#에 XMP 메타데이터를 추가하는 단계

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. EPS 파일 입력 스트림을 초기화합니다.
  3. PsDocument Class 를 사용하여 스트림에서 PS 파일을 만듭니다.
  4. XMP 메타데이터를 가져오려면 GetXmpMetadata() 메서드를 사용합니다.
  5. 변경된 EPS 문서는 Save() 메소드를 이용하여 저장합니다.

XMP 메타데이터를 추가하는 C# 코드

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

XMP 메타데이터를 EPS 파일 C#으로 편집하는 단계

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. EPS 파일 입력 스트림을 초기화합니다.
  3. PsDocument 클래스를 사용하여 스트림에서 PS 파일을 만듭니다.
  4. XMP 메타데이터를 가져오려면 GetXmpMetadata() 메서드를 사용합니다.
  5. XMP 메타데이터 값을 변경하려면 SetArrayItem() 메서드를 사용합니다.
  6. 변경된 EPS 파일을 저장합니다.

XMP 메타데이터를 변경하는 C# 코드

    // 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 파일 C#의 XMP 메타데이터를 가져오는 단계

  1. 문서 디렉토리의 경로를 설정하십시오.
  2. EPS 파일 입력 스트림을 초기화합니다.
  3. PsDocument 클래스를 사용하여 스트림에서 PS 파일을 만듭니다.
  4. GetXmpMetadata() 메서드를 사용하여 XMP 메타데이터를 가져옵니다.

XMP 메타데이터를 가져오는 C# 코드

    // 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();
    }



자주하는 질문

1. XMP 메타데이터란 무엇입니까?

XMP는 Extensible Metadata Platform의 약어로, 미디어 파일에 메타데이터 속성을 삽입하기 위한 표준입니다.

2. XMP에는 어떤 정보가 포함되어 있나요?

버전, 제목, 설명, 키워드, 파일을 고유하게 식별할 수 있는 식별자 및 기록 정보와 함께 애플리케이션의 작성자, 편집자 및 작성자에 대한 정보가 있습니다.

3. EPS 파일에 XMP 메타데이터를 추가하는 방법은 무엇입니까?

문서 디렉터리의 경로를 설정하고 스트림에서 EPS 파일을 만듭니다. XMP 메타데이터를 추가하려면 XmpMetadata 클래스의 Add() 메서드를 사용하세요.

EPS EPS 파일 형식이란 무엇입니까?

EPS(ERSF) 또는 캡슐화된 포스트스크립트 파일 형식은 실제로 단일 페이지가 어떻게 생겼는지 설명하는 PS 프로그램 형식입니다. PostScript 그래픽을 다른 문서에 캡슐화하는 데 도움이 되는 특정 참고 사항과 PS가 실제로 제한되어 있습니다. EPS는 벡터 그래픽 또는 결합된 벡터 래스터 그래픽을 완벽하게 지원합니다. 형식의 특징은 문서로 가져오는 즉시 더 이상 편집할 수 없다는 것입니다. 이것이 이 형식을 작업할 수 있는 형식으로 변환하는 이유 중 하나입니다.