Document properties in Word and PDF files

Note that both DocumentProperties.BuiltIn and DocumentProperties.Custom are dictionaries, so you can either use TryGetValue to try retrieving the “DocType” value or use ContainsKey method to check if the “DocType” key exists.

For instance, something like this:

var document = DocumentModel.Load("ovl-last.docx");
var documentProperties = document.DocumentProperties;
if (document.DocumentProperties.Custom.TryGetValue("DocType", out object ovldoctype))
{
    // ...
}

Or this:

var document = DocumentModel.Load("ovl-last.docx");
var documentProperties = document.DocumentProperties;
if (document.DocumentProperties.Custom.ContainsKey("DocType"))
{
    var ovldoctype = documentProperties.Custom["DocType"];
    // ...
}

Regarding the “PDF Producer”, try adding the “Producer” property:

documentProperties.Custom.Add("Producer", "My value for PDF Producer");
document.Save("ovl-last.pdf");

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top