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
- 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 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
- 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 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
- 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 the Document instance.
- 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
- Create a
Document
object. - Create two
Page
objects and add to the Document object. - Create a
XmpMetadata
object and set its properties. - Create a
RightsManagementSchema
object and assign it to the XmpMetadata object instance. - Set the necessary properties for the RightsManagementSchema object.
- Add the XmpMetadata object instance to the Document 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();
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
- 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 the XmpMetadata object. - Set the BasicSchema object's properties.
- Add the XmpMetadata instance to the Document instance (note that the Basic 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();
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.
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.
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
andLabel
) - 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.
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX