Images

Ways to insert an image into a Word document using Documotor

It is possible to insert images from data. In contrast to other bindings, a Picture content control is used instead of a Rich text content control, and the content control must already be present in the template - it cannot be added inside the editor. Like with other bindings, the JSON object containing the binding is added to the tag of the created content control. The different binding types determine what happens when the shapes of the image and the content control do not match.

🚧

To add an Image binding using the Binding Editor, a Picture content control must be already present in the template.

BindingDescription
FillImageCrops image to fill out the entire content control in the template. The image is compressed.
FitImageThe entire image is shown inside of the content control. Any empty space is set to transparent. The image is compressed.
RawFillImageSimilar to Fill, but uses Word's native cropping feature. This improves performance, but can result in a larger presentation since the image is not resized.
RawFitImageSimilar to Fit, but uses Word's native cropping feature. This improves performance, but can result in a larger presentation since the image is not resized.
StretchImageThe entire image is shown inside of the content control, and the image is stretched to fill it out if needed.

If you know the shape of the image, that is, the ratio of width and height, it's recommended to set the shape of the Picture content control to match it. In this case, all the binding types will yield the same result. All formats supported in Word are also supported in Documotor. Note that Microsoft 365 support for .webp is lacking.

All the image bindings have the same parameters.

Parameters

{ "BindingType": "ImageBinding", "BindingKey": "ImagePath", "BindingHyperlink": "HyperlinkPath" }

string BindingType

One of the image bindings, "FillImage", "FitImage", "RawFillImage", "RawFitImage" or "StretchImage".

JSON path ImagePath

A path to a string that is either a base64 string or a public URL. If it is a URL, the image will be downloaded and embedded in the generated document.

JSON path HyperlinkPath [optional]

A path to a string which is a URL. If the parameter is included, the image will act as a hyperlink to HyperlinkPath.