Working with Templates
This topic provides information about creating, modifying, and deleting templates.
Introduction
Spruce enables you to create customized templates for your unique business needs. In general, a template contains a document with various objects, including Pages, Body, Blocks, Paragraphs and Lines. You can insert Boxes and conditional statements around many of these objects.
This topic takes you through steps for creating many of the elements that comprise a template. To view an example of how these elements display in Spruce, see Template Tree View It also provides instructions for modifying, deleting, exporting, and importing your templates.
Selecting Template Viewing Options
Before you create a template, select the options to apply to your screen displays from the View menu. The options you choose determine how your data displays.
To choose your options
- Select the View menu on the Spruce UI main window, and click Options.
The Options dialog displays.
- Click one of these option buttons in the Unit of Measure area:
• | Inches |
• | Centimeters |
• | Points |
For example, if you choose Inches, Spruce screens will display with inches as units of measure, as appropriate.
This option controls only how values are displayed in the Spruce UI and does not affect how they are stored in the template XML.
- Enter the appropriate numerical values in the Template Page field and the Data Page field in the Real Precision area.
This option specifies the number of decimal digits that will display when you print a real number. Valid values range from 0 through 7. The settings control only how real values are displayed in the Spruce UI and do not affect how they are stored or emitted onto the document pages.
Creating a Template
To create a template
1. | From the Template menu, click New. |
Or
From the Template Toolbar, click the New icon.
The New Template dialog displays.
2. | Enter the name of the template in the Template Name input field, and click OK. |
In this example, the Sample Statement template name is used. The name of the template you are creating displays in the tree on the left side of the screen with the Template icon next to it. The default format and document properties display to the right of the screen, and the name of the template displays at the top of the screen.
3. | Create a Color to be used with your template. |
a. | From the Template Tree view, select and right-click Format } Append } Color. |
Or
From the Template Tree view, expand Format to display Style Default. Right-click Style Default and select } Insert } Color.
The “Color” Properties dialog displays.
a. | Enter the name of the color in the Color Name input field. |
Or
Select a standard color from the list below the input field drop-down. You also can create a custom color.
a. | Click OK. |
Your Color object displays under the document section of the Template Tree view.
4. | Create a Style for your template. |
a. | From the Template Tree view, select and right-click Format } Append } Style. |
Or
From the Template Tree view, select and right-click Style:Default } Insert } Style.
The “Style” Properties dialog displays.
a. | Enter a name for the style and complete any other appropriate fields to specify the desired style properties (e.g., font, font height, font width, and font color). |
The font, fontcolor, overline, underline, just (justification), linecolor, and fillcolor have drop-down lists of available values.
b. | Click OK. |
5. | Create a Tab for your template. |
a. | From the Template Tree view, select and right-click Format } Append } Tab. |
Or
From the Template Tree view, select and right-click Style:Default } Insert } Tab.
The “Tab” Properties dialog displays.
a. | Enter a name for the tab, and complete the fields with the appropriate information. |
b. | Click OK. |
6. | Create a Page or Pages for your template. |
a. | From the Template Tree view, select and right-click Document } Append } Pages. |
The “Pages” Properties dialog displays.
b. | Enter the appropriate information in the fields in the right column (e.g., the type of paper stock, page orientation, etc.). |
c. | Click OK. |
After you create pages, each page and its associated Pages icon display in the Template Tree view. If you expand the icon, Spruce automatically generates a Body icon since a Pages object can contain only one Body. You can add Headers and Trailers as needed.
7. | Create a Block for your template. |
a. | From the Template Tree view, select and right-click Document } Append } Block. |
Or
From the Template Tree view, select and right-click the Pages object you just created } Insert } Block.
The “Block” Properties dialog displays.
a. | Enter the appropriate information in the fields in the right column. |
The block represents the area within the document in which you will place text and/or graphics. Enter the location and dimensions. The Positioning and Page Attributes sections of the “Block” Properties dialog have lists of drop-down lists of available values. See Block Properties for detailed field descriptions.
b. | Click OK. |
8. | Create a Box for your template. |
a. | From the Template Tree view, select and right-click Document } Append } Box. |
Or
From the Template Tree view, select and right-click the block you just created } Insert or Append } Box.
The “Box” Properties dialog displays.
a. | Enter the appropriate information in the fields in the right column. |
The linetype, filltype, and style fields all have drop-down lists of available values. Enter the appropriate numerical values in the extend up, extend down, extend left, and extend right fields. See Box Properties for detailed field descriptions.
b. | Click OK. |
You can also create Box by surrounding an existing object. (See Surrounding an Object for more information.)
9. | Create a Paragraph for your template. |
a. | From the Template Tree view, select and right-click the box you just created } Append } Paragraph. |
Or
From the Template Tree view, select and right-click the box you just created } Insert } Paragraph.
The “Paragraph” Properties dialog displays.
a. | Enter the appropriate information in the fields in the right column. |
The style and just (justification) fields have drop-down lists of available values.
Select one of these justification types: center, full left, and right.
b. | Click OK. |
10. | Create a Line for your template. |
a. | From the Template Tree view, select and right-click the paragraph you just created } Append } Line. |
The Line Editor dialog displays.
The Line Editor is where you enter the data in XML format. This data displays in your output documents. Documents are stored in the DocuVault in internal Cypress format.
b. | Type the desired text in the Line Editor dialog. This text displays on the page in the location of the Block that contains this Line. |
c. | Click Validate to ensure that the XML text is correct. |
• | If the text is correct if this message box displays: |
• | If the text is incorrect, an error message displays. |
d. | Right-click in the Line Editor dialog to display this context-sensitive menu: |
The Line Editor enables you to Insert all of the items listed on the menu when you are creating a line. It also enables you to use the Surround, Copy, Cut, Delete, Paste, and Select All options. For more information, see Line Editor Properties
11. | Create a Header for your template. |
a. | From the Template Tree view, select and right-click the Pages object you created earlier } Append } Header. |
Or
From the Template Tree view, select and right-click the Body that was automatically created } Insert } Header.
The “Header” Properties dialog displays.
a. | Enter the appropriate information in the fields in the right column. Select from the available values on the drop-down lists. See Header Properties for detailed field descriptions. |
b. | Click OK. |
12. | Create a Trailer for your template. |
a. | From the Template Tree view, select and right-click the Pages object you created earlier } Append } Trailer. |
The “Trailer” Properties dialog displays.
b. | Enter the appropriate information in the fields in the right column. Select from the available values on the drop-down lists. See Trailer Properties for detailed field descriptions. |
c. | Click OK. |
While creating a template, you can click the Document tab or the Document button to view how your output document will look. See Document Tab
Using INCLUDE Templates
Include templates are especially helpful for adding common objects to larger templates without having to re-create them, thus saving time and duplication.
To create an include template
1. | From the Template menu, click New. |
Or
Click the New button.
The New Template dialog displays.
2. | Type the name of the include template in the Template Name input field (e.g., Example Include Template). |
3. | Select the Is an INCLUDE template check box so the check mark displays. |
4. | Click one of the option buttons that display in the Include Type area. |
• | Format contains Colors, Styles, and Tabs. |
• | Document contains objects such as Blocks or Boxes with the document level. |
• | Block contains objects such as Paragraphs with the block level. |
5. | Click OK. |
Several changes occur in the Spruce UI main window:
• | The Include template displays in the tree view on the far left side of the screen and the new name of the Include template displays below the main Include with their respective icons , . |
• | The Tree view and Text view are available. |
• | The Schema, Sample Data, and Document tabs are deactivated or grayed out. |
6. | Add the desired colors, styles, and tabs to the Format Include template the same way you created and added them when you created the template. SeeCreating a Template. |
7. | Click Save when you are finished specifying properties for your INCLUDE template. |
To incorporate an include template into an existing template
1. | Using the previous examples, select the “Sample Statement” template and click the Tree tab to display the tree view. |
2. | Expand the Format section of the template and right-click on a color, style, or tab of your choice } Insert } Format Include. |
The “Format Include” Properties dialog displays.
3. | Type the name of the include template in the Format Include Name input field. |
Or
Select a name from the drop-down list of existing include templates.
For this example, select the Example Include Template you just created.
4. | Click OK. |
The original Sample Statement template now contains the new Example Include Template you just created. The Include template displays in the Template Tree view and its associated icon is highlighted in yellow.
5. | Refresh the dialog by clicking one of the tabs at the bottom of the right pane of the Spruce UI main window (e.g., Document). Then click the Template tab to return to the Tree view. |
You can see the changes in the Template Tree view. The elements that comprise the Include template are highlighted in yellow.
When an Include template is first inserted or appended, it displays as a single generic icon. After the template has been reloaded (e.g., by clicking the Document tab), the Include template is expanded to show its actual contents. The icons are highlighted in yellow and the contents cannot be modified.
Cloning Templates
Cloning is a convenient feature that allows you to copy an existing template with all of its attributes. You can then give the template a new name and modify only those items you wish to change, without having to create a brand new template from scratch.
To clone a template
1. | On the left side of the Spruce UI main window, under DocuVault, click the name of the template you want to copy. |
2. | From the Template menu, click Clone. |
Or
Click the Clone icon on the Shortcut toolbar.
The New Template dialog displays.
3. | Enter a name for the new template in the Template Name input field. |
4. | Click OK. |
The new template name displays under the DocuVault tree structure.
Resetting Templates
If you modify your template then decide to discard the changes without deleting the entire template, you can use the Reset feature in Spruce.
To reset a template
1. | If you make modifications to your template, then decide not to keep them, click the Reset icon. |
Or
From the Template menu, click Reset.
This message box displays:
2. | Click Yes to disregard your changes and reload the last saved version of the template. |
Or
Click No to continue.
Working with Schemas
A schema describes the layout of incoming XML data. You can add, delete, and define variables and arrays within a schema.
Schema consists of the global and document sections. The global section describes data items that appear only once in the data and apply to the entire Spruce execution. You can add or delete variables in the global section. The document section describes data items that are repeated in the data file for each individual document created by Spruce. You can add or delete variables or arrays in the document section.
An array is a list of variables that can be repeated as many times as necessary in the data file. Nested arrays are supported (up to 10 levels deep) with these requirements:
• | All array names must be unique. For example, if array A contains arrays B and C, array D cannot also contain arrays with the names of A, B, or C. |
• | Variable names can be reused in different arrays. For example, arrays A and B can both contain a variable X. |
• | An array must contain at least one child (either an array or a variable). A completely empty array will generate a schema error. |
The Tree view displays the data type (i.e., string, integer, real, or boolean) for each object in the schema. See Schema Tree View
The step-by-step process in this section details how a variable for customer country is added to the schema, using the Sample Statement template.
To add a variable to the schema
1. | From the Schema Tree view, expand the document section and right-click cust_zip[integer] } Insert } variable to display the Schema “variable” Properties dialog. |
2. | Type the name of the variable in the name input field. |
When adding variables:
• | The first character in the name of the variable must be a letter or underscore, followed by any combination of letters, numbers, and underscores. |
• | You can use uppercase and lowercase letters. |
• | Do not use spaces or special characters in the variable name. |
• | Ensure that the name you choose for the variable is not a duplicate. |
3. | Select string from the drop-down list to display in the type field. |
4. | Click OK. The new variable now displays in the Schema Tree view. |
Working with Sample Data
Sample data is generated as you create your schema. It is test data that will be displayed only, not the real data in your output documents. It is used, however, to create sample documents to show you what your output documents will look like. You can test to see if your variable data will display properly by clicking the Document tab at the bottom of the main panel. The Tree and Text views display the data type (i.e., string, integer, real, or boolean) for each object in the sample data.
• | The global section contains the global variables or variables that will be present in all of your documents (for example,company name). You can view variable properties and change values in the respective properties dialogs here. |
• | The document section contains the variables that will change for each customer (e.g., customer name) and the item details for each customer (e.g., the check amount, date, and description). You can view the properties in this section and change the values in the respective properties dialogs here. You also can add or delete item details before or after another item detail. |
The step-by-step processes detailed in this section illustrate how you can change Sample Data to verify that your template is working correctly. The Sample Statement template and associated Sample Data are used in this section.
To review sample data
1. | Select the Sample Statement template in the navigation panel on the Spruce UI main window. |
2. | Click the Sample Data tab at the bottom of the main panel, then click the Tree tab to display the sample data for the Sample Statement in the Tree view. |
3. | Click the plus sign next to global, document, and the first few occurrences of checks to display the associated detail. Note the items highlighted in yellow. These items display where changes occur as you change data to test your template. |
4. | Click the Text tab to display the related XML. |
5. | Click the Document tab to display the test output document. The highlighted data that will be compared to the test data when you change object values in the next section. |
To test data by changing object values
1. | From the Sample Data Tree view for the Sample Statement template, right-click the “cust_addr2 [string]” object } Properties to display the cust_addr2 Properties dialog. |
2. | Enter Apt. 5496 in the value input field. |
3. | Click OK. In the Tree view, the value of the cust_addr2 [string] object changes to Apt. 5496. |
4. | Right-click the check_amount [real] object } Properties to display the chk_amount Properties dialog. |
5. | Type 920.73 over the existing value, 845.30 in the value input field. |
6. | Click OK. The value of the chk_amount [real]object changes to 920.73 in the Tree view. |
7. | Click the Document tab to display how the output document will look. |
• | Compare the highlighted portion of the customer’s address in the output document to the original one at the beginning of this section. “Apt. 5496” was added to the original address. |
• | Compare the highlighted portion of the check amount in the output document values above, to the check amount value in the original output document. The amount changed from $845.30 to $920.73. |
The test Sample Data shows that the template is working properly and the address and cost values changed as expected. You can apply this method of testing on all of the objects within the Sample Data.
To add before, add after, or delete item detail objects
1. | In the Tree view, right-click an existing detail item to display Add Before, Add After, and Delete. |
2. | Click Add Before to add the item detail object above the selected item. |
Or
Click Add After to add the item detail object below the selected item.
Or
Click Delete to delete the item detail object.
This feature allows you to create additional data or delete existing data and to modify properties for testing varying amounts of data.
Modifying Templates
Once you have created a template, you always can modify it later. You can add new items, delete existing items, or modify the properties of existing items. The first step-by-step process in this section demonstrates adding a new Block to the existing Sample Statement template that was created at the beginning of this topic. See Creating a Template.
To add a new item to an existing template
1. | From the Template Tree view, select and right-click an existing block in the template tree } Insert } Block. |
The “Block” Properties dialog displays.
2. | Enter the appropriate information in the fields in the right column. See Block Properties for detailed field descriptions. |
To modify an item in an existing template
1. | From the Template Tree view, select and right-click an existing block in the template tree } Properties. |
The “Block” Properties dialog displays.
2. | Change the values in the appropriate fields. |
3. | Click OK. |
To delete an item in an existing template
1. | From the Template Tree view, select and right-click an existing block. |
2. | Click Delete } Save. |
The item is removed from the template and from the Template Tree view.
Deleting Templates
To delete a template
1. | Highlight by clicking the name of the template in the Template Tree view. |
2. | Click the Delete icon. |
This message displays.
3. | Click Yes. |
The screen is cleared, the template deleted permanently, and the name of the template is removed from the list of template names under your DocuVault.
Or
Click No.
The delete request is canceled and your template remains intact.
Exporting Templates
Spruce enables you to export templates and include templates from your DocuVault to disk files for backup or importing into other DocuVaults.
To export a template
1. | From the Template Tree view in the Spruce DocuVault, highlight the name of the template you want to export. (In this example we are using the Sample Statement template.) |
2. | From the Template menu, click Export. |
Or
Click the Export icon on the shortcut toolbar.
The Export Template dialog displays.
3. | Click the browser button on the right side of the dialog to locate the directory to which you want to export the template. |
The Open dialog displays.
4. | Enter in the File name field the name of the file to which you want the template written, and click Open. |
The path and the template file name display in the Template File field.
5. | Repeat step 4 for File, Schema File, and Data File. |
6. | Click OK. |
The template is now exported to the directory or DocuVault of your choice.
Or
Click Cancel, to cancel the your changes.
To export an include template
1. | From the Template Tree view in the Spruce DocuVault, highlight the name of the include template you want to export. |
2. | From the Template menu, click Export. |
Or
Click the Export icon on the shortcut toolbar.
The Export Template dialog displays.
3. | Click the browser button on the right side of the dialog to locate the directory to which you want to export the template. |
The Open dialog displays.
4. | Enter in the File name field the name of the file to which you want the include template to be written, and click Open. |
The path and the include template file name display in the Template File field.
5. | Click OK. |
The include template is now exported to the directory or DocuVault of your choice.
Or
6. | Click Cancel, to cancel the your changes |
Importing Templates
Spruce enables you to import templates and include templates into your DocuVault from disc files that have been exported from the same or another DocuVault.
To import a template
1. | From the Template menu, click Import. |
Or
Click the Import icon on the shortcut toolbar.
The Import Template dialog displays.
2. | Type the name of the template in the Template Name input field. |
3. | Click the browser button on the right side of the dialog to locate the directory from which you want to import. |
The Open dialog displays.
4. | Browse to the desired directory. Files with extensions of .xml and .xsd display. |
5. | Click the template file of your choice, and click Open. |
The Open dialog displays.
6. | The directory path and template name automatically display in the Import Template dialog. |
7. | Repeat steps 3 through 5 for the schema and data files, so that all three fields have the necessary entries. |
8. | Select the Remove DocuVault References check box if you are importing this template from a different DocuVault. |
9. | Click OK. |
The template is now imported and the name displays under your DocuVault in Spruce.
Or
Click Cancel, to cancel the your changes
To import an include template
1. | From the Template menu, click Import. |
Or
Click the Import icon on the shortcut toolbar.
The Import Template Dialog displays.
2. | Click the Include tab. |
The Import Template dialog displays with the information for importing include templates.
3. | Type the name of the include template in the Include Name input field. |
4. | Click the browser button on the right side of the dialog to locate the directory from which you want to import. |
The Open dialog displays.
5. | Click the include template file of your choice, and click Open. |
The path and the include template file name display in the Include file title field.
6. | Select one of the three options in the Include Type area (e.g., select the Format option for an include template that has formatting objects). |
7. | Select the Remove DocuVault References check box if you are importing this Include template from a different DocuVault. |
8. | Click OK. |
The include template is now imported and the name displays under your DocuVault in Spruce.
Or
9. | Click Cancel, to cancel the your changes. |
Using an Alternate Input File or XSL Style Sheet with a Template
You can specify an input file to use with a template. Additionally, you can select an XSL style sheet to be used to transform the data into XML data.
To specify an alternate input file
1. | Select a template in the tree view, and right-click. The context menu is displayed. |
2. | Select Alternate Input. The Alternate Input dialog is displayed. |
3. | Enter the path for the input file you want to use in the Input Data File field. |
Or
Click the Browse button to locate and select the file you want to use.
4. | Click the Validate against Schema button to test the input file against the template’s schema. |
The input file data is validated against the schema. An message displays to indicate whether the validation was successful or failed.
• | If the validation failed, details for the error display in the message area in the bottom pane. Click OK to close the message and return to the Alternate Input dialog. |
• | If the validation is successful |
5. | Optional. Repeat steps step 3. - step 4. . |
6. | Click OK. |
To specify an XSL style sheet
1. | Select a template in the tree view, and right-click. The context menu is displayed. |
2. | Select Alternate Input. The Alternate Input dialog is displayed. |
3. | Enter the path for the style sheet file you want to use in the Use XSL StyleSheet field. |
Or
Click the Browse button to locate and select the file you want to use.
4. | Click the Perform XSL data transformation to file button. The Open dialog is displayed. |
5. | Enter a name for the file in which you want to store the resulting XML data. |
The XML data is validated against the schema. An error message displays if the transformation fails:
Details for the error display in the message area in the bottom pane.
If an error message displays, click OK to close the message and return to the Alternate Input dialog.
6. | Optional. Repeat steps step 3. - step 5. . |
7. | Click OK. |
Surrounding an Object
Spruce enables you to surround an object or group of objects in the template with other objects. For example, a Block, a Column, or a Line can be surrounded by a Box, which will draw an outlined or shaded box around this object.
This function is useful when you have designed a template and you decide later that some object needs a Box around it, but all that content is already built. To add the Box without using the Surround function, you would have to delete all this content that was already built, create the Box, and then recreate all the content inside. To avoid doing all this, Spruce allows you to surround any appropriate content with a surrounding object without having to do anything to the original content.
For example, suppose a Block has been built that contains several Paragraphs and Lines, each with some rather complex content, along with some If and For objects, and you then decide that you want the Block to be shaded.
To surround a Block with a shaded Box
1. | Click on the Block. |
2. | Select the Surround menu item. |
3. | Select Box. |
4. | Configure the “Box” Properties dialog by selecting shade from the drop-down list for the filltype field. (See Box Properties for detailed field descriptions.) |
5. | Click OK. |
6. | Select how much of the content is to be included within this Box. |
7. | Click OK. |
Spruce then adds the Box to the tree with all the selected content within it.
Likewise, you can decide to remove a surrounding object, such as to remove a Box from around a set of Blocks.
To remove a Box from around a set of Blocks
1. | Click on the Box. |
2. | Select the Remove Surround Object menu item. |
The Remove Surround Object menu item will remove this object, leaving the content inside intact.
Objects that are allowed to surround other objects vary by what type of object is selected.