Assembling Multiple Documents
HotDocs enables you to create templates that assemble multiple documents. To use this functionality in your host application, you must implement support for multiple assemblies.
ASSEMBLE instruction
To assemble a document using the Cloud Services API, you make a call to the assemble document method for a specific template. If the template contains one or more ASSEMBLE instructions, it adds the templates referenced by the ASSEMBLE instruction to a pending assemblies list.
Referenced Templates in HotDocs Package files
If a template is referenced by an ASSEMBLE instruction in the parent template, the referenced template is bundled in the same HotDocs Package file when the parent template is uploaded to Cloud Services. This means that when making assemble document requests for subsequent templates, you use the same package ID as used when assembling the parent template.
Pending Assemblies list
The Pending Assemblies list contains a list of template names for templates requested by ASSEMBLE instructions in the completed assembly.
When you receive a response from the assemble document call and save the resulting files to disk, you see a meta0.xml file. This file contains information about the completed assembly, including template name and file format. It also contains a pending assemblies list. For example:
<PendingAssemblies> <PendingAssembly> <TemplateName>Template2.docx</TemplateName> <TemplateName>Template3.docx</TemplateName> </PendingAssembly> </PendingAssemblies>
You use the template names in the list to make assemble document requests to the Cloud Services API.
Using the Pending Assemblies list
Once the document is assembled and a meta0.xml file is created, your host application must:
- Read the meta0.xml file.
- Get the list of template names from PendingAssemblies.
- Make assemble document requests for each template in the list, using:
- The same package ID as used for the initial assemble document request
- the template name as the value for the templatename parameter in the request.
- When the subsequent assemble document requests return a response, you should check the resulting meta0.xml file for any further pending assemblies.