Hi Team,
currently we are using the Aspose.Words for updating the document properties inside the word document. Now we got a new requirement from the info sec to check if it is possible to add the properties to windows document properties itself with some custom properties. check the screenshot.

is there any API to perform this?
@Sai_Prasad
To update the Windows document properties in a Word document using Aspose.Words, you can utilize the CustomDocumentProperties
class. This allows you to add custom properties that can be viewed in the Windows file properties dialog.
Here’s a brief overview of how you can achieve this:
- Load the Document: First, you need to load the Word document you want to modify.
- Access Custom Document Properties: Use the
CustomDocumentProperties
property of the Document
class to access the custom properties.
- Add or Modify Properties: You can add new custom properties or modify existing ones.
Here’s a sample code snippet in C# that demonstrates how to add custom document properties:
using Aspose.Words;
using Aspose.Words.Properties;
class Program
{
static void Main()
{
// Load the document
Document doc = new Document("YourDocument.docx");
// Access custom document properties
CustomDocumentProperties customProperties = doc.CustomDocumentProperties;
// Add custom properties
customProperties.Add("Authorized", true);
customProperties.Add("Authorized By", "John Smith");
customProperties.Add("Authorized Date", DateTime.Today);
customProperties.Add("Authorized Revision", doc.BuiltInDocumentProperties.RevisionNumber);
customProperties.Add("Authorized Amount", 123.45);
// Save the document
doc.Save("UpdatedDocument.docx");
}
}
In this example, we load a document, add several custom properties, and then save the document. You can replace the property names and values with those that meet your specific requirements.
Make sure to check the properties in the Windows file properties dialog after saving the document to confirm that your custom properties have been added successfully.
If you need further assistance or have specific requirements, feel free to ask!
Sources:
[1]: Working with document properties.cs
Thanks!, is it specific to MS office files or irrespective of any file extension?
@Sai_Prasad Aspose.Words works with MS Word documents. If you need to process other files, you can consider using other Aspose products:
https://docs.aspose.com/
i dont see doc.CustomDocumentProperties() API
image.png (57.4 KB)
Thanks @alexey.noskov . i can see the custom properties are added but i still need to open the document and check the properties added or not.
my requirement is, when right click to the document file and select properties. i need to see the properties added in the details tab which is more of not opening the file and verifying if the properties are added.
@Sai_Prasad Could you please specify exactly what properties you need to set and if possible please provide your input and expected output (with properties set) documents?
Use Case.docx (140.2 KB)
@alexey.noskov, added the use case with screenshot.
@Sai_Prasad Screenshots are not useful for analysis. So could you please attach your input and expected output documents here for testing?