By default, imported child documents bring in their own styles and properties. You can configure your imported templates to use the styles in the parent template instead, so the final output has a consistent look and feel. This article will introduce you to the Parent Formatting sample that ships with AutoTag and show you how to import child documents both with or without the parent document styling.
Before you are able to use the example provided below you will need to first setup your working environment correctly.
- If you are using Windward Version 13 you need to follow these steps
- If you are using Windward Version 14 or higher you need to follow these steps
- Numbered lists are currently unsupported. Please see this article for more information.
- Bulleted lists are supported.
A basic example ships with Windward in our AutoTag/templates directory. The example consists of three documents.
- Import Master Parent Formatting - Template.docx
- Import Subdocument - Template.docx
- Import SubSubdocument - Template.docx
In our example here, we will be working with the Master Parent Formatting template and the Import Subdocument template.
The parent template contains an Import Tag with the property settings below depending on your version.
Version 13 only
- Import Tag property use_parent_format set to true.
Version 14 and higher
- Import Tag property import.use.child.styles set to true.
The styles are defined in the text and image below.
- Normal style text that is Calibri font and black in color.
- green header background
- orange footer background
The Import Tag in the parent template references an XML node that contains the filename of the child template to be imported, in this case Import Subdocument – Template.docx. The styles are defined in the text and image below.
- Normal style text that is Comic Sans font and red in color.
- yellow header background
- black footer background
You will notice in image below the footer appears as gray because headers and footers are shown as faded when viewed onscreen in Word, but it is really black.
When the parent template is run and the Import Tags are processed the final report is generated with all child templates processed and imported.
- The styles that have the same name, i.e., Normal, will have the changed attributes of that style (Calibri text and black font) applied to each section of text where that style has been set in the child documents.
- The headers and footers of the child documents are also no longer present and have assumed the headers (green) and footers (orange) of the parent template.
At long last our marketing director can rest easy because is no trace of Comic Sans in the final output document!
NOTE: The child template contains another Import Tag reference to another child template, making the final report generation 3 levels deep. We have not shown this child-child template here, but we note it here so you will understand what you are seeing on the last two pages of the document when you work with the AutoTag sample yourself.