Posted by a ceTe Software moderator
Hello,
There is no option available in DynamicPDF Merger API to dynamically validate xmp metadata in a PDF. You could catch the System.Xml.XmlException however.
You can read and update xmp metadata using version 9 and later DynamicPDF Merger product. Below is the code sample to read xmp meta date from an existing PDF:
PdfDocument pdf = new PdfDocument(@"C:\Temp\MyDocument.pdf");
string xmpString = pdf.XmpMetadata;
You can add new xmp meta data to the PDF using XmpMetadata property of MergeDocument class. Below is the code sample. If you are wanting to add custom metadata then you will need to build respective schemas and add it to the XmpMetaData object. You can refer to the documentation on adding new xmp metadata to the PDF
here.
PdfDocument pdf = new PdfDocument(@"C:\Temp\MyDocument.pdf");
MergeOptions options = new MergeOptions();
options.XmpMetadata = false;
MergeDocument doc = new MergeDocument(pdf, options);
// Create an Xmp Metadata
XmpMetadata xmp = new XmpMetadata();
// Add the Xmp metadata to the document. This will add default metadata to the PDF.
doc.XmpMetadata = xmp;
doc.Draw(@"C:\Temp\MyOutput.pdf");
Thanks,
ceTe Software Support Team