> For the complete documentation index, see [llms.txt](https://docs.feathery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.feathery.io/platform/document-autofill-and-signatures/autofill-document-templates/word-doc-autofill.md).

# Word Doc Autofill

Automatically fill and route Word doc templates from your form or AI data.

If you use a Word doc template, you can include variables in your document via double-curly brace syntax (`{{Field1}}`). Feathery will automatically replace variables with the corresponding field value when you fill them out.

{% hint style="warning" %}
Fields can only contain **letters, numbers, and underscores** when being used in Word Doc Autofill. Other characters may cause the generation to fail by reading the field name as a formula instead.
{% endhint %}

## Creating the Word Doc Template

Feathery supports [Jinja templating logic](https://documentation.bloomreach.com/engagement/docs/jinja-syntax) for advanced use cases such as conditionally showing/hiding sections, generating sections in a loop, formulas, and more.

### Conditional Logic

You can support conditionally showing or hiding any content / pages using the `{%p` syntax show below:

```
{%p if display_paragraph %}
One or many paragraphs
{%p endif %}
```

In this example, we have a checkbox field called `display_paragraph` in our form that is either true or false.

The first and last paragraphs (those containing `{%p ... %}` tags) will never appear in generated Word doc, regardless of the `display_paragraph` value.

Here only:

```
One or many paragraphs
```

will appear in the generated docx if `display_paragraph` is True, otherwise, no paragraph at all are displayed.

You can insert anything within the tag, such as paragraphs, whole pages, etc.

### Embed Images

To embed an image into the document that was pulled from a form submission, use the following Jinja syntax:

```
{{ <FileUploadFieldId>__Image_<width>_<height> }}
```

`FileUploadFieldId` is the ID of the file upload field that the image to embed was uploaded to. `Width` is the width of the embedded image, in millimeters. `Height` is the height of the embedded image, in millimeters.

## Set Template Field Values

After your Word template has been uploaded, you can use [logic rules](https://docs.feathery.io/platform/build-forms/advanced-logic/visual-rule-builder/set-field-value-action.md) and hidden fields to set the template fields to custom values. This allows you to achieve complex logic that was set up during the templating step.

<figure><img src="https://640450274-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHAVngDAEk3s8Bw7P6Ntz%2Fuploads%2FuTrzqxsUrMPqTc13ud2m%2Fword_logic.png?alt=media&amp;token=677b0aa1-f0e1-4e2d-ba18-3e8cb46882db" alt="" width="375"><figcaption><p>Custom rules and hidden fields can be combined to create complex logic.</p></figcaption></figure>

## Document Workflow

Once you've mapped your document, you can integrate it into your existing workflow for filling and routing to the desired location. For example, you can include your document as an attachment in a custom [email integration](https://feathery.io/integrations/email) to be sent to recipients.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.feathery.io/platform/document-autofill-and-signatures/autofill-document-templates/word-doc-autofill.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
