Products Technologies Demo Docs Blog Support Company

Maintaining Custom Document Properties

Custom properties can be used to store additional information about the document in the document itself. This article explains how to load and save these properties.

Maintaining Custom Document Properties

Custom properties are used to store additional information in a document. These properties remain with a document and can be viewed by all MS Word users that open the document. Several property management servers provide data tracking capabilities to search for, sort, and track documents based on document properties.

In TX Text Control, these properties can be accessed and created using the UserDefinedPropertyDictionary class.

The UserDefinedPropertyDictionary class is used with the LoadSettings.UserDefinedDocumentProperties and SaveSettings.UserDefinedDocumentProperties properties. Each entry in the dictionary is a key/value pair, where the key is the name of the document property and the value is the document property's value.

In order to access these properties when loading a document, you will have to use the LoadSettings in the Load method.

var loadedProperties;

using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{ 
    tx.Create();
    
    TXTextControl.LoadSettings loadSettings = new TXTextControl.LoadSettings();
    tx.Load(docFile, TXTextControl.StreamType.WordprocessingML, loadSettings);

    if (loadSettings.UserDefinedDocumentProperties != null)
    {
       loadedProperties = loadSettings.UserDefinedDocumentProperties;      
    }
}

On saving the document, you will have to pass the dictionary using the SaveSettings in the Save method.

TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings()
{
        UserDefinedDocumentProperties = loadedProperties
};

tx.Save(editedFile, TXTextControl.StreamType.WordprocessingML, saveSettings);

It is important to pass these properties explicitly when saving the document. Otherwise, the properties are not maintained during the save method.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

  • TXTextControl.LoadSettings.UserDefinedDocumentProperties Property
  • TXTextControl.SaveSettings.UserDefinedDocumentProperties Property
  • TXTextControl.UserDefinedPropertyDictionary Class

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETWindows FormsWPF

TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 2 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format

Maintaining the integrity and functionality of documents throughout their lifecycle is paramount. TX Text Control provides a robust ecosystem that focuses on preserving documents in their internal…


ActiveXASP.NETWindows Forms

Expert Implementation Services for Legacy System Modernization

We are happy to officially announce our partnership with Quality Bytes, a specialized integration company with extensive experience in modernizing legacy systems with TX Text Control technologies.


ActiveXASP.NETWindows Forms

Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5

TX Text Control 33.0 Service Pack 1 and TX Text Control 32.0 Service Pack 5 have been released, providing important updates and bug fixes across platforms. These service packs improve the…