Skip to main content

XmpMetadata

Version: 11.0

cete.dynamicpdf.xmp.xmpmetadata

XmpMetadata​

This class represents the XMP metadata for a PDF document.

public class XmpMetadata : Resource
Public Class XmpMetadata
Inherits Resource

Inheritance: Object → Resource → XmpMetadata

Examples​

This example shows how to create an Xmp Metadata and Add it to the document.

Imports System
Imports System.IO
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.Xmp

Module MyModule

Sub Main()

' Create a PDF Document
Dim MyDocument As Document = New Document
MyDocument.Keywords = "XMP, metadata, pdf, example"
MyDocument.Title = "Pdf document with xmp metadata"

' Add blank pages to the document
MyDocument.Pages.Add(New Page(PageSize.Letter))
MyDocument.Pages.Add(New Page(PageSize.Letter))

' Create an Xmp Metadata
Dim MyXmp As XmpMetadata = New XmpMetadata

' Dublin Core Schema.
Dim Mydc As DublinCoreSchema = MyXmp.DublinCore
Mydc.Contributors.Add( "Abc" )
Mydc.Contributors.Add( "Xyz" )
Mydc.Contributors.Add( "Pqrs" )
Mydc.Coverage = "To test all the attributes of schema's provided"
Mydc.Creators.Add( "MyProduct" )
Mydc.Creators.Add( "MyCompany" )
Mydc.Date.Add( DateTime.Now )
Mydc.Description.AddLang( "en-us", "XMP Schema's test" )
Mydc.Identifier = "First XMP pdf"
Mydc.Publisher.Add( "mydomain.com" )
Mydc.Publisher.Add( "My Company" )
Mydc.Relation.Add( "test pdf with xmp" )
Mydc.Rights.DefaultText = "US English"
Mydc.Rights.AddLang( "en-us", "All rights reserved 2012, MyCompany." )
Mydc.Source = "XMP Project"
Mydc.Subject.Add( "eXtensible Metadata Platform" )
Mydc.Title.AddLang( "en-us", "XMP" )
Mydc.Title.AddLang( "it-it", "XMP - Piattaforma Estendible di Metadata" )
Mydc.Title.AddLang( "du-du", "De hallo Wereld" )
Mydc.Title.AddLang( "fr-fr", "XMP - Une Platforme Extensible pour les Métédonnées" )
Mydc.Title.AddLang( "DE-DE", "ÄËßÜ Hallo Welt" )
Mydc.Type.Add( "Pdf file containing xmp metadata" )

' Basic Schema.
Dim Mybs As BasicSchema = MyXmp.BasicSchema
Mybs.Advisory.Add( "Date" )
Mybs.Advisory.Add( "Contributors" )
Mybs.Nickname = "xyz"
Mybs.Thumbnails.Add(106, 80, "JPEG", GetImage("C:\thumbnail.jpg"))

' Rights Management Schema.
Dim Myrm As RightsManagementSchema = New RightsManagementSchema
Myrm.Marked2 = CopyrightStatus.PublicDomain
Myrm.Owner.Add( "MyCompany" )
Myrm.UsageTerms.AddLang( "en-us", "Contact MyCompany" )

' Basic Job Ticket Schema.
Dim MyJob As BasicJobTicketSchema = New BasicJobTicketSchema
MyJob.JobRef.Add( "MyCompany", "Xmp Test", new Uri( "http://www.mydomain.com/" ) )
MyJob.JobRef.Add( "MyCompany", "XMP Metadata", new Uri( "http://www.mydomain.com/" ) )

' Paged-Text Schema.
Dim Mypt As PagedTextSchema = New PagedTextSchema

' Add the Xmp Metadata to the document
MyDocument.XmpMetadata = MyXmp

' Save the PDF document
MyDocument.Draw("C:\MyDocument.pdf")

End Sub

Private Function GetImage(ByVal filePath As String) As Byte()

Dim MyInFile As FileStream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
Dim MyBinaryData(MyInFile.Length) As Byte
MyInFile.Read(MyBinaryData, 0, MyInFile.Length)
MyInFile.Close()
return MyBinaryData

End Function

End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.xmp;

public class Example
{
public static void CreatePDF(string outputPath, string imagePath)
{
// Create a PDF Document
Document document = new Document();
document.Keywords = "XMP, metadata, pdf, example";
document.Title = "Pdf document with xmp metadata";

// Add blank pages to the document
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));

// Create an Xmp Metadata
XmpMetadata xmp = new XmpMetadata();

// Dublin Core Schema.
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");
dc.Type.Add("Pdf file containing xmp metadata");

// Basic Schema.
BasicSchema bs = xmp.BasicSchema;
bs.Advisory.Add("Date");
bs.Advisory.Add("Contributors");
bs.Nickname = "xyz";
bs.Thumbnails.Add(106, 80, "JPEG", GetImage(imagePath));

// Rights Management Schema.
RightsManagementSchema rm = new RightsManagementSchema();
rm.Marked2 = CopyrightStatus.PublicDomain;
rm.Owner.Add("MyCompany");
rm.UsageTerms.AddLang("en-us", "Contact MyCompany");

// Basic Job Ticket Schema.
BasicJobTicketSchema job = new BasicJobTicketSchema();
job.JobRef.Add("MyCompany", "Xmp Test", new Uri("http://www.mydomain.com/"));
job.JobRef.Add("MyCompany", "XMP Metadata", new Uri("http://www.mydomain.com/"));

// Paged-Text Schema.
PagedTextSchema pt = new PagedTextSchema();

// Add the Xmp Metadata to the document
document.XmpMetadata = xmp;

// Save the PDF
document.Draw(outputPath);
}

private static byte[] GetImage(string filePath)
{
FileStream inFile = new FileStream(filePath, FileMode.Open, FileAccess.Read);
byte[] binaryData = new byte[inFile.Length];
inFile.Read(binaryData, 0, (int)inFile.Length);
inFile.Close();
return binaryData;
}
}

Remarks​

For more details on using XMP metadata take a look at the XMP Metadata topic.

Constructors​

XmpMetadata()​

Initializes a new instance of the XmpMetadata class.

public XmpMetadata()
Public Sub New ()

Properties​

BasicSchema​

Gets the BasicSchema schema object.

public BasicSchema BasicSchema { get; }
Public Property BasicSchema As BasicSchema

Property Value​

BasicSchema

DublinCore​

Gets the DublinCoreSchema schema object.

public DublinCoreSchema DublinCore { get; }
Public Property DublinCore As DublinCoreSchema

Property Value​

DublinCoreSchema

RequiredPdfObjects​

Gets the number of PDF objects required by the resource.

public int RequiredPdfObjects { get; }
Public Property RequiredPdfObjects As Int32

Property Value​

Int32

ResourceType​

Gets the type of resource. (Inherited from Resource)

public ResourceType ResourceType { get; }
Public Property ResourceType As ResourceType

Property Value​

ResourceType

Uid​

Gets the unique ID of the resource. (Inherited from Resource)

public long Uid { get; }
Public Property Uid As Int64

Property Value​

Int64

Methods​

AddSchema(XmpSchema)​

Adds a given Xmp Schema to the schema list.

public void AddSchema(XmpSchema schema)
Sub AddSchema(schema As XmpSchema)

Parameters​

XmpSchema object to add to the schema list.

Draw(DocumentWriter)​

Draws the xmp metadata to the DocumentWriter object.

public void Draw(DocumentWriter writer)
Sub Draw(writer As DocumentWriter)

Parameters​

DocumentWriter object to write xmp output.

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

See Also​

ceTe.DynamicPDF.Xmp