Examples

Add XMP Metadata to PDFs

Use DynamicPDF Core Suite for .NET to add a Basic Job Ticket Schema, Dublin Core Schema, Paged-Text Schema, Rights Management Schema, or an XMP Basic Schema to a PDF. The following C# examples show you how.

How to Add Basic Job Ticket Schema to PDF

The following steps and C# sample code illustrate adding a Basic Job Ticket Schema to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding Basic Job Ticket Schema to a PDF Document


  1. Create a Document object.
  2. Create two Page objects and add to the Document instance.
  3. Create an XmpMetadata object and set its properties.
  4. Create a BasicJobTicketSchema object and assign it to the XmpMetadata instance.
  5. Set the BasicJobTicketSchema object's properties.
  6. Add an XmpMetadata object to the Document object.
  7. Save the PDF document.

Sample Code - C#


Document document = new Document();

document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
            
XmpMetadata xmp = new XmpMetadata();
            
BasicJobTicketSchema job = new BasicJobTicketSchema();
job.JobRef.Add("MyCompany", "Xmp Test", new Uri("http://www.mydomain.com/"));
job.JobRef.Add("MyProduct", "XMP Metadata", new Uri("http://www.mydomain.com/"));
xmp.AddSchema(job);

document.XmpMetadata = xmp;
            
document.Draw(@"Output.pdf");        

How to Add Dublin Core Schema to PDF

The following steps and C# sample code illustrate adding the Dublin Core Schema to a PDF document using Dynamic Core Suite.


Steps for Adding the Dublin Core Schema to a PDF Document


  1. Create a Document object.
  2. Create two Page object instances and add to the Document object.
  3. Create an XmpMetadata object and set its properties.
  4. Create a DublinCoreSchema object and assign it to the XmpMetadata object instance.
  5. Set the DublinCoreSchema properties as set in the sample code below.
  6. Add the XmpMetadata object to the Document object (note that the Dublin Core Schema is internally added automatically).
  7. Save the PDF document.

Sample Code - C#


Document document = new Document();

document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
            
XmpMetadata xmp = new XmpMetadata();
            
DublinCoreSchema dc = xmp.DublinCore;
dc.Contributors.Add("Abc");
dc.Contributors.Add("Xyz");
dc.Contributors.Add("Pqrs");
dc.Coverage = "To test all the attributes of schema's provided";
dc.Creators.Add("MyProduct");
dc.Creators.Add("MyCompany");
dc.Date.Add(DateTime.Now);
dc.Description.AddLang("en-us", "XMP Schema's test");
dc.Identifier = "First XMP pdf";
dc.Publisher.Add("mydomain.com");
dc.Publisher.Add("MyCompany");
dc.Relation.Add("test pdf with xmp");
dc.Rights.DefaultText = "US English";
dc.Rights.AddLang("en-us", "All rights reserved 2012, MyCompany.");
dc.Source = "XMP Project";
dc.Subject.Add("eXtensible Metadata Platform");
dc.Title.AddLang("en-us", "XMP");
dc.Title.AddLang("it-it", "XMP - Piattaforma Estendible di Metadata");
dc.Title.AddLang("du-du", "De hallo Wereld");
dc.Title.AddLang("fr-fr", "XMP - Une Platforme Extensible pour les Métédonnées");
dc.Title.AddLang("DE-DE", "ÄËßÜ Hallo Welt");

document.XmpMetadata = xmp;
            
document.Draw(@"Output.pdf");        

How to Add Paged-Text Schema to PDF

The following steps and C# sample code illustrate adding a Paged-Text Schema to PDF document using DynamicPDF Core Suite.


Steps for Adding Paged-Text Schema to PDF Document


  1. Create a Document object.
  2. Create two Page objects and add to the Document object.
  3. Create an XmpMetadata object and set its properties.
  4. Create a PagedTextSchema object and assign to the XmpMetadata object.
  5. Set the PagedTextSchema object's properties.
  6. Add the XmpMetadata object to the Document instance.
  7. Add the Draw method to output the PDF document.

Sample Code - C#


Document document = new Document();

document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
            
XmpMetadata xmp = new XmpMetadata();
            
PagedTextSchema pt = new PagedTextSchema();
xmp.AddSchema(pt);

document.XmpMetadata = xmp;
            
document.Draw(@"Output.pdf");        

How to Add Rights Management Schema to PDF

The following steps and C# sample code illustrate adding a Rights Management Schema to a PDF document using DynamicPDF Core Suite.


Steps for Adding Rights Management Schema to a PDF Document


  1. Create a Document object.
  2. Create two Page objects and add to the Document object.
  3. Create a XmpMetadata object and set its properties.
  4. Create a RightsManagementSchema object and assign it to the XmpMetadata object instance.
  5. Set the necessary properties for the RightsManagementSchema object.
  6. Add the XmpMetadata object instance to the Document object.
  7. Add the Draw method to output the PDF document.

Sample Code - C#


Document document = new Document();

document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
            
XmpMetadata xmp = new XmpMetadata();
            
RightsManagementSchema rm = new RightsManagementSchema();
rm.Marked2 = CopyrightStatus.PublicDomain;
rm.Owner.Add("Company Name");
rm.UsageTerms.AddLang("en-us", "Contact MyCompany");
xmp.AddSchema(rm);

document.XmpMetadata = xmp;
            
document.Draw(@"Output.pdf");        

How to Add XMP Basic Schema to PDF

The following steps and C# sample code illustrate adding an XMP Basic Schema to a PDF document using DynamicPDF Core Suite.


Steps for Adding an XMP Basic Schema to a PDF Document


  1. Create a Document object.
  2. Create two Page instances and add to the Document object.
  3. Create a XmpMetadata object and set its properties.
  4. Create a BasicSchema object and assign to the XmpMetadata object.
  5. Set the BasicSchema object's properties.
  6. Add the XmpMetadata instance to the Document instance (note that the Basic Schema is internally added automatically).
  7. Add the Draw method to output the PDF document.

Sample Code - C#


Document document = new Document();

document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
            
XmpMetadata xmp = new XmpMetadata();
            
BasicSchema bs = xmp.BasicSchema;
bs.Advisory.Add("Date");
bs.Advisory.Add("Contributors");
bs.Nickname = "xyz";
bs.Thumbnails.Add(106, 80, "JPEG", imageData); //imageData is byte array

document.XmpMetadata = xmp;
            
document.Draw(@"Output.pdf");        

GitHub Project

An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub


Clone or View Example Project on GitHub

DynamicPDF Core Suite for .NET Information


DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!



More Information on XMP Metadata

Available on Other Platforms

DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.


Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!