Lesson 1: Create a base template
Start by creating a base template in Document Studio and
adding a table element.
About this task
Procedure
- Open the Document Studio application.
- Create a template by clicking File > New > Document template.
- Add elements and formatting to your template:
- From the Palette view, select a
Paragraph element and place it
into the template content editor. - Select a
Text element and place it inside the
paragraph element. - Select the text element you just placed into the template content editor.
- In the Properties view, expand formatting > font.
- For the bold property, enter true.

- Select a
Table element and place it after the
paragraph element. - In the New table window, enter 1 row and 3 columns. Click OK.
- From the Palette view, select the
Container element and place it into
the table element. 
- In the Palette view, click
Select. - Select the row element in the template and drag it into
the container element.

- Select the
Text element and drag it into each
of the three cells. 
- From the Palette view, select a
- Add a name and width to the first cell element:
- Select the first cell.
- In the Properties view, expand Metadata.
- For the name property, enter Cell 1.
- Expand formatting > specific.
- For the cell width property, enter 50.
- Add a name and width to the second, middle cell element:
- Select the second cell.
- In the Properties view, expand Metadata.
- For the name property, enter Cell 2.
- Expand formatting > specific.
- For the cell width property, enter 50.
- Add a name and width to the third cell element:
- Select the third cell.
- In the Properties view, expand Metadata.
- For the name property, enter Cell 3.
- Expand formatting > specific.
- For the cell width property, enter 150.
- Create a variable:
- In the Outline view, right-click Variables and click Insert > New Variable.
- In the Name field, enter iteration_.
- Leave the default selections for the remaining fields and click OK.
- Assign the iteration_ variable to
the container element:
- Select the container element.
- In the Properties view, for the Assignments property,
click the
Configuration icon.
- In the Assignments editor window, click Add.
- Select the iteration_ variable and click OK.
- Click the Script expression tab.
- Expand Variables.
- Select the iteration_ variable.
- Copy and paste the following script
into the script editor:
Even though there is only one row displayed in the template, this script adds a row for each variable.iteration_*1 + 1 - Click OK and OK to close the windows.
- Add a script to the container element:
- Select the container element.
- Expand formatting > specific.
- In the do while condition property,
click the
Configuration icon.
- Click the Script expression tab.
- Expand Variables.
- Select the iteration_ variable.
- Copy and paste the following script
into the script editor:
Even though there is only one row displayed in the template, this script creates four rows in the output.iteration_*1 < 4 - Click OK.
- Add a script to the Text element in Cell 1:
- Select the Text element in Cell 1.
- In the Properties view, for the Content property,
click the
Configuration icon.
- Click the Script expression tab.
- Expand Variables.
- Select the iteration_ variable.
- Copy and paste the following script
into the script editor:
This script enters the Greek text in the first row and enters short text in all subsequent rows.if ( iteration_* 1 == 1) { "Lorem ipsum dolor sit amet" } else { "short text" } - Click OK.
- Add a script to the Text element in Cell 2:
- Select the Text element in Cell 2.
- In the Properties view, for the Content property,
click the
Configuration icon.
- Click the Script expression tab.
- Expand Variables.
- Select the iteration_ variable.
- Copy and paste the following script
into the script editor:
This script enters the Greek text in the first row and enters short text in all subsequent rows.if ( iteration_* 1 == 1) { "consectetur adipiscing elit." } else { "short text" } - Click OK.
- Add a script to the Text element in Cell 3:
- Select the Text element in Cell 3:
- In the Properties view, for the Content property,
click the
Configuration icon.
- Click the Script expression tab.
- Expand Variables.
- Select the iteration_ variable.
- Copy and paste the following script
into the script editor:
This script enters the Greek text in the first row and enters short text in all subsequent rows.if ( iteration_* 1 == 1) { "Aliquam et arcu ut dolor dapibus dapibus ac non urna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare sollicitudin semper. Suspendisse accumsan accumsan nisi, et posuere ante rhoncus sit amet. Ut hendrerit, purus ut ullamcorper accumsan, orci eros accumsan lorem, ut fringilla nisi orci et nisi. Maecenas nec leo at nunc aliquam mattis. " } else { "short text" } - Click OK.
- Save the template as a base for the remaining tutorial lessons. Click File > Save and select an output name and location. Example: C:\Documents and Settings\Administrator\Desktop\table_sizing_tutorial\table_sizing_tutorial-lesson1_base.dta
Results

Lesson checkpoint
You created a template, added elements to the template,
created a variable, and wrote scripts for the text elements.
Feedback