TX Text Control Blog

Using Custom Document Properties to store additional document information

Björn Meyer

Blogged by Björn Meyer on February 9, 2017 and tagged with sample, reportingcloud, windows forms, wpf, asp.net.


Custom properties can be used to store additional information about the document in the document itself. 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 our reference implementation ReportingCloud, a reporting template can be edited online using our HTML5-based Web.TextControl. Additionally, JSON objects can be uploaded to be used as data sources in the online editor. When opening a template, a JSON data source must be selected from which merge fields and blocks should be added to the template.

Using Custom Document Properties to store additional data

To prevent that the user needs to select this data source again and again every time the document is edited, the association between the template and the data source should be stored somewhere. To keep everything as simple as possible, we decided to store the connected data source in the document itself by creating a custom document property.

When the document is edited, the selected data source name is stored in the document in the Controller code:

A new UserDefinedPropertyDictionary is created and a new custom property with the unique name rc_datasource is created with the value of the selected data source. This dictionary can be added to the UserDefinedDocumentProperties of the SaveSettings class. Finally, the document is saved with the created SaveSettings object.

When the overview page is loaded the next time, the data source can be selected in the drop-down list by reading the custom property from the document:

The stored custom properties are available in the UserDefinedDocumentProperties of the LoadSettings class.

The custom document properties provide a very flexible way of storing additional data to documents without keeping them in a separate database. The data is directly stored where it belongs to - the document.

This feature is available in TX Text Control X14. Download a trial version to test this on your own.

 
 
Call us: +1 704-544-7445 (United States)
 
 

Products

Support

Downloads

Corporate

Buy Now

About Text Control

Founded in 1991, Text Control is an award-winning Visual Studio Industry Partner and leading vendor of word processing and reporting components for Microsoft development technologies. The products help thousands of developers add comprehensive word processing functionality to their applications. Text Control is 100% self-owned and independent of all investor decisions. Customers benefit from these years of experience, large user-base, and at the same time, appreciate developing with a mature, reliable product.

SD Times 100SD Times 100SD Times 100SD Times 100SD Times 100SD Times 100Visual Studio 2015 Launch PartnerVisual Studio 2013 Launch PartnerVisual Studio 2012 Launch PartnerVisual Studio Partner