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
- Create a
Document
object. - Create two
Page
objects and add to theDocument
instance. - Create an
XmpMetadata
object and set its properties. - Create a
BasicJobTicketSchema
object and assign it to theXmpMetadata
instance. - Set the
BasicJobTicketSchema
object's properties. - Add an
XmpMetadata
object to theDocument
object. - 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
- Create a
Document
object. - Create two
Page
object instances and add to the Document object. - Create an
XmpMetadata
object and set its properties. - Create a
DublinCoreSchema
object and assign it to the XmpMetadata object instance. - Set the
DublinCoreSchema
properties as set in the sample code below. - Add the
XmpMetadata
object to the Document object (note that the Dublin Core Schema is internally added automatically). - 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
- Create a
Document
object. - Create two
Page
objects and add to the Document object. - Create an
XmpMetadata
object and set its properties. - Create a
PagedTextSchema
object and assign to the XmpMetadata object. - Set the
PagedTextSchema
object's properties. - Add the
XmpMetadata
object to theDocument
instance. - 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
- Create a
Document
object. - Create two
Page
objects and add to theDocument
object. - Create a
XmpMetadata
object and set its properties. - Create a
RightsManagementSchema
object and assign it to theXmpMetadata
object instance. - Set the necessary properties for the
RightsManagementSchema
object. - Add the
XmpMetadata
object instance to theDocument
object. - 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
- Create a
Document
object. - Create two
Page
instances and add to the Document object. - Create a
XmpMetadata
object and set its properties. - Create a
BasicSchema
object and assign to theXmpMetadata
object. - Set the
BasicSchema
object's properties. - Add the
XmpMetadata
instance to theDocument
instance (note that the Basic Schema is internally added automatically). - 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
- C# - XmpMetadataExample.cs
- VB.NET - XmpMetaDataExample.vb
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!
- DynamicPDF Core Suite for .NET Product Page
- [DynamicPDF Core Suite for .NET Documentation](/docs/dotnet/dynamic-pdf-core-suite-welcome ")
More Information on XMP Metadata
- Refer to the XMPMetadata documentation topic
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.
- DynamicPDF Generator
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX
- DynamicPDF Merger
- Java - DynamicPDF Merger for Java
- COM/ActiveX - DynamicPDF Merger for COM/ActiveX