Using dynamic text with Data Driven Pages
Having dynamic text is an important part of authoring a successful series of Data Driven Pages. Using dynamic text allows important information on the page layout to change dynamically as you go from one page to another. This information includes text for page titles, page numbers, labels for neighboring pages (a neighboring page is one that is geographically adjacent to the current page), and other index layer attributes.
You can access Data Driven Pages dynamic text elements directly from Insert on the main menu or from the pull-down list on the Data Driven Pages toolbar.
Page name
Each page in the map series needs a name, and the names are taken from this field. As Data Driven Pages iterates through the features in the index layer and each page is defined, the attribute value for the chosen name field is used as the page name.
Element |
Description |
Syntax |
---|---|---|
Data Driven Page Name |
This corresponds to the current value of the attribute field set as the name field in the Setup Data Driven Pages dialog box. |
<dyn type="page" property="name"/> |
You can add a data-driven-page name to your layout from Insert on the main menu or from the pull-down list on the Data Driven Pages toolbar.
Page number and page with count
Data Driven Pages allows you to define a page number. The page number can be based on field values of the index layer. These values can be alphanumeric. You can also use dynamic text to display the total count of pages with the page, or index, number for the current page. For example, "Page 3 of 10".
Element |
Description |
Syntax |
---|---|---|
Data Driven Page Number |
This dynamic text element, if applicable, corresponds to the current value of the attribute field set as the Data Driven Page Number on the Setup Data Driven Pages dialog box. Otherwise, the pages are numbered in increments of one, starting with the value set as Starting Page Number. |
Page <dyn type="page" property="number"/> |
Data Driven Page with Count |
This uses the index value of the current page along with the total number of pages. For example, you may have 10 Data Driven Pages where the starting page number is set to 3. The result for this tag for the first page would be Page 1 of 10. |
Page <dyn type="page" property="index"/> of <dyn type="page" property="count"/> |
You can add these dynamic text elements to your layout from Insert on the main menu or from the pull-down list on the Data Driven Pages toolbar.
Layer attributes and display expressions
Often, you will want to include dynamic text to show attribute values for a particular page. All the attribute values of the Data Driven Pages index layer are available for dynamic display. For example, if you have an attribute on the index layer named POPULATION, you can create a dynamic text tag using the field name to dynamically display the POPULATION values for each page in the layout. If you wish to create dynamic text elements based on a combination of the contents of multiple index layer fields and your own text, use the layer's display expression.
Element |
Description |
Syntax |
---|---|---|
Data Driven Page Attribute | This corresponds to the current value of a selected attribute of the index layer for the given data driven page. This includes fields joined to the index layer. The default behavior, domainlookup="true"/>, is to use coded value descriptions if they are available. If you do not want to use coded value descriptions change domainlookup="true"/> to domainlookup="false"/>. | <dyn type="page" property="attribute" field="<Field Name>" domainlookup="true"/> |
Data Driven Page Display Expression | This corresponds to the Display Expression set in the Display tab of the Layer Properties dialog box. Using the display expression you can create a more complex dynamic text element by combining the contents of multiple fields with your own text. | Page <dyn type="page" property="expression"/> |
![Tip Tip](rsrc/tip.png)
If the dynamic text you are adding to your layout is too long and you want to enter a line break you can do this by editing the attribute field in the table by using SHIFT+ENTER.
You can add these dynamic text elements to your layout from Insert on the main menu or from the pull-down list on the Data Driven Pages toolbar.
How to add dynamic text for an index layer attribute
- Click Insert > Dynamic Text on the main menu.
- Choose Data Driven Page Attribute.
- Choose the attribute you want to use from the Index layer field drop-down list and click OK.
Using dynamic text to create neighbor labels
You can use the Calculate_Adjacent_Fields geoprocessing tool to create and populate fields that can be used to label neighboring pages. If you are creating a strip map and use the Strip Map Index Features geoprocessing tool to create the index layer, the layer has precalculated fields for left-right and top-bottom labels.
Here is an example, from layout view, of a Data Driven Page with a number of dynamic text elements.
![]() |
Here is how the dynamic text is structured for each example:
Number |
Description |
Syntax |
---|---|---|
1 | See Page name, number and page count above | |
2 |
A neighbor label with a value. These tags are constructed such that <dyn type="page" property="Field_Name">, where Field Name is the name of the attribute field holding the name value of the adjacent, or neighboring, page in a particular direction. If you do not have these fields you can use the Calculate Adjacent Fields geoprocessing tool to create and populate fields that can be used to label neighboring pages. |
<dyn type="page" property="PageName_E"/> |
3 |
A neighbor label with static text included in the text element along with the dynamic tag. The label has a value. The preStr and postStr tag attributes let you specify text to add to the start or end of a parsed dynamic tag. These only appear when the corresponding dynamic tag has a value. |
<dyn type="page" property="PageName_S" preStr="The neighbor south is " postStr="."/> |
4 |
A neighbor label with no static text. The label has no value. |
<dyn type="page" property="PageName_W"/> |
5 |
A neighbor label with no value. There is a dynamic text attribute to use static text in cases where there is no value. The emptyStr tag attribute lets you specify specific text to display if the dynamic tag has no value ([empty]). |
<dyn type="page" property="PageName_NW" emptyStr="No neighbor"/> |
Here is what the page will look like when exported or printed:
![]() |
When the dynamic text tag returns [empty], nothing will be exported or printed. If a text element string parses to nothing, [empty] is shown on the display, but nothing is shown when printing or exporting. This lets you know that a text element is present, but the value the dynamic tag is referring to is currently null.
How to add dynamic text for neighbor labels
These steps assume that you already have the needed fields and values as part of your Data Driven Pages index layer to create the labels. If you do not have these fields you can use the Calculate Adjacent Fields geoprocessing tool to create and populate fields that can be used to label neighboring pages.
- Click Insert > Dynamic Text > Data Driven Page Name from the main menu.
Not all dynamic text elements are available from the menu. You can manually edit existing text elements. Adding an available Data Driven Pages dynamic text element from the menu saves you the step of having to type in the type tag. It is already there.
- Click the Select Elements tool
on the Draw toolbar, select the text element you just added, then drag to where you want it on the layout.
For example, the label for neighboring pages to the north of the current page should be placed at the center top of the layout page. Of course, this assumes that the map rotation is constant and is zero.
- Double-click the text element.
- Change the value for the property tag to the field name for the page value you want to use.
For example, if the field name for the page to the north is "PageName_N", you would enter "PageName_N" as the property value. The dynamic text element would look like this: <dyn type="page" property="PageName_N"/>.
- Repeat this for additional neighbor labels.