Examples

Adding XMP metadata to PDF

Use DynamicPDF Core Suite to add a Basic Job Ticket Schema, Dublin Core Schema, Paged-Text Schema, Rights Management Schema, and an XMP Basic Schema to PDFs.

How to Add Basic Job Ticket Schema to PDF in C#

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

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 in C#

The following steps and 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 in C#

The following steps and 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. 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();
            
PagedTextSchema pt = new PagedTextSchema();
xmp.AddSchema(pt);

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

How to Add Rights Management Schema to PDF in C#

The following steps and 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. 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();
            
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 in C#

The following steps and 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. 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();
            
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

Clone or view the example project at GitHub. This example code is contained in the Examples/XmpMetadataExample.cs file.

Clone or View Example Project on GitHub

Getting Started

NuGet Package

DynamicPDF Core Suite is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The easiest way to install the package is using the Visual Studio Package Manager, but you can also download directly from NuGet.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

DynamicPDF Core Suite contains over 75 page elements so you can add rich content to the PDFs you create:

  • Images
  • Text Objects (TextArea and Label)
  • HTML
  • Barcodes (47 types)
  • Form Fields
  • Charts

Refer to the Dynamic PDF Core Suite website for more information.

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!