Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Document Variables

Document Variables provide a mechanism to store information in the document in a key-value format. DocumentVariableField is a Field element used to access and display the value, which corresponds to the given field-argument. The argument is the name of the variable.


RadFlowDocument has a DocumentVariableCollection property, which holds document variable records. The collection maps string keys to string values. You can add a record in it through an indexer or with the collection's Add() method. Example 1 demonstrates both approaches.

Example 1: Add document variable record

RadFlowDocument document = new RadFlowDocument(); 
document.DocumentVariables["Job"] = "Software Engineer"; 
document.DocumentVariables.Add("Name", "Nancy Davolio"); 

The code in Example 1 adds two document variables – "Name", which will be evaluated to "Nancy Davolio", and "Job" with "Software Engineer" value.

The same two methods can be used to modify the value of an existing variable in the collection.

Removing defined variables can be achieved by using the Remove() method of the variables collection. It accepts the name of the variable as a parameter.

Example 2: Remove document variable record


Field Syntax


The syntax of a document variable field code is pretty simple as demonstrated on Figure 1.

Figure 1: Document variable field code syntax

Rad Words Processing Concepts Document Variables 01


A DocumentVariable field can be inserted through RadFlowDocumentEditor's InsertField() method. Example 3 shows insertion of the field created in Example 1.

Example 3: Insert document variable field

editor.InsertField("DOCVARIABLE Name", "«Nancy Davolio»"); 

See Also

In this article