Application.AssembleDocument2 Method

This method assemblies a document from a template and answer collection.

Syntax

void AssembleDocument2(string TemplatePath, HDAssemblyOptions options, _AnswerCollection ansColl, string DocumentPath, object outputOptions);

Parameters Description
TemplatePath The path to the template.
options Flags that specify how the document should be assembled. See HDAssemblyOptions for details.
ansColl The answer collection. This provides the answers required to assemble the document.
DocumentPath The path of the document that will be assembled from the template. The extension provided designates the requested format of the document. If the document extension provided is not supported for the template format, an error occurs, and an exception is thrown.
outputOptions Options specific to the file format of the output document. This parameter may be null, _PdfOutputOptions, _HtmlOutputOptions, or _TextOutputOptions. If not null, the parameter type must match the format of the document path file extension.

Example

The following example shows you how to use an answer file to assemble a document (with assemble options set to none), then output the file as a pdf:

public class ExampleCode
{
    static void Main()
    {
        HotDocs.Server.Interop.Application app = new HotDocs.Server.Interop.Application();
         
        string templatePath = @"C:\temp\Demo Employment Agreement.docx";
        HotDocs.Server.Interop.HDAssemblyOptions options = HotDocs.Server.Interop.HDAssemblyOptions.asmOptNone;
        HotDocs.Server.Interop.AnswerCollection ansColl = new HotDocs.Server.Interop.AnswerCollection();
        ansColl.Open(@"C:\temp\EmployeeAnswers.anx");
        string documentPath = @"C:\temp\EmployeeOutput.pdf";
        HotDocs.Server.Interop.PdfOutputOptions outputOptions = new HotDocs.Server.Interop.PdfOutputOptions();
         
        app.AssembleDocument2(templatePath, options, ansColl, documentPath, outputOptions);
    }
}