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
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);
//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);
Console.WriteLine("Inner Text : " + element.InnerText);
}
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
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";
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("\n");
XmlNode element = (XmlNode)ienum.Current;
Console.WriteLine("Inner Text : " + element.InnerText);
}
Comments
Post a Comment