PDF Toolkit

Samples

Get and Set XMP to/from PDF

This Code sample requires the PDF Toolkit and is found in: C:\Aquaforest\PDF Toolkit\samples\SetAndGetXMPMetadata


using Aquaforest.PDF;
using System;
using System.Xml;
    
namespace SetAndGetXMPMetadata
{
    class Program
    {
        static PDFDocument doc;
    
        static void Main(string[] args)
        {
            SetXMP();
    
            GetXMP();
        }
    
        static void SetXMP()
        {
            XmlDocument xmp = new XmlDocument();
            xmp.Load(@"..\..\..\documents\source\xmp.xml");
    
            doc = new PDFDocument(@"..\..\..\documents\source\releasenotes.pdf");
            doc.SetXMPMetadata(xmp);
            doc.Save(@"..\..\..\documents\output\releasenotes_xmp.pdf");
        }
    
        static void GetXMP()
        {
            doc = new PDFDocument(@"..\..\..\documents\source\pdf_with_images.pdf");
            string xmp = doc.GetXMPMetadata();
    
            Console.WriteLine(xmp);
        }
    }
}