How To Add & Get Custom Meta Data To PDF or PDF/A

Here I use Syncfusion.Pdf.Base.dll to add custom meta data to PDF type documents.


This DLL uses XMP based framework to define document properties for Adobe type documents. It is based on RDF which is W3C standard for XMP based Meta data. Adobe designed the standard XMP schemas.amework permits the integration of any schema that is structured in accordance with the specification.


Some Examples for Adobe XMP Schemas
  •   XMP Basic Schema
  •   Adobe PDF Schema
  •   Dublin Core Schema
  •   Custom Schema     
You can get more info from : http://www.pdfa.org/doku.php?id=artikel:en:pdfa_metadata        

Now We Will See How To Deal with Meta Data using Syncfusion.Pdf.Base.dll

First make a reference to particular DLL (Select & Right click on the project name in 'solution explorer' -> Add Reference ->  Browse -> Give the path of DLL)


Then add this source code to code file


//import these packages


   
     using Syncfusion.Pdf;
     using Syncfusion.Pdf.Xmp;
     using Syncfusion.Pdf.Parsing;



//Add custom meta data


    PdfLoadedDocument pdf = new PdfLoadedDocument(@"D:\10.1.1.85.7166.pdf");
    XmpMetadata xmp = new XmpMetadata(pdf.DocumentInformation.XmpMetadata.XmlData);

    CustomSchema custom = new CustomSchema(xmp, "custom", "http://www.syncfusion.com/");
        custom["Company"] = "Test";
        custom["Website"] = "http://www.syncfusion.com/";
        custom["Product"] = "Essential PDF";

//save pdf
         pdf.Save(@"D:\10.1.1.85.7166.pdf");     




//Get custom meta data


        PdfLoadedDocument pdf = new PdfLoadedDocument(@"D:\10.1.1.85.7166.pdf");
        XmpMetadata xmp = new XmpMetadata(pdf.DocumentInformation.XmpMetadata.XmlData);

        CustomSchema custom = new CustomSchema(xmp, "custom", "http://www.syncfusion.com/");
        IEnumerator ienum = custom.XmlData.GetEnumerator();
        while (ienum.MoveNext())
        {
            Console.WriteLine("\n");
            XmlNode element = (XmlNode)ienum.Current;
            if (element.HasChildNodes) Console.WriteLine("\n" + "Element Name : " + element.LocalName);
           Console.WriteLine("Inner Text : " + element.InnerText);
          
        }








 

Comments

Popular posts from this blog

How to add standard and custom Metadata to PDF using iTextSharp

How to set and get Metadata to image using BitmapMetadata class in C#

How to generate direct line token to start a new conversation between your own client application and bot framework in Java