Add images, photos, and signatures to your custom print template so they appear in the correct position when a form result is downloaded as a PDF.
|
Before you start
|
What is supported
Both Word (.docx) and Excel (.xlsx) templates support images and signatures, but Excel has more restrictions. Use Word unless you specifically need Excel.
| Capability | Word (.docx) | Excel (.xlsx) |
|---|---|---|
| Single image from an image upload question | ✓ | ✓ |
| Multiple images from an image upload question | ✓ | – |
| Images from within a group question (multiple responses) | ✓ | – |
| Signatures | ✓ | ✓ |
Understanding image dimensions
Image codes use two numbers to control the output size: width and height, in pixels.
|
{$id1|insert_image:300:0} ^ ^ width:height (0 = auto) |
- Setting height to 0 preserves the original aspect ratio of the uploaded image. This is recommended in most cases.
- Setting a specific height forces the image to that exact size, which may cause it to appear stretched or compressed.
- Adjust the width value to control how large images appear in the PDF output.
Word templates (.docx)
Single image
Use this code for an image upload question where Multiple is not ticked. Replace {$id1} with the code for your image question from the Custom Printing panel.
| {$id1|insert_image:300:0} |
|
Important: Multiple checkbox
|
Multiple images
When an image question has Multiple ticked, the worker can upload more than one photo. Use one of the following codes to display all uploaded images.
An image upload question with Multiple ticked. The worker can upload more than one photo when submitting the form.
First, find the code for your image question in the Custom Printing panel. When Multiple is ticked, the code includes the insert_image syntax automatically.
The Custom Printing panel showing Q10 (Images of Traffic Management) with code {$id1.id10|insert_image:300:0}. The question is inside a group question, so the code is nested.
Choose a layout option based on how you want the images arranged in the PDF:
|
Horizontal layout (images side by side): {foreach from=$id5 item=_picture} {$_picture|insert_image:300:0} {/foreach}
Vertical layout (images stacked): {listrow from=$id5 item=_picture} {$_picture|insert_image:300:0} {/listrow}
One image per table row: {tablerow from=$id5 item=_picture} {$_picture|insert_image:300:0} {/tablerow} |
- foreach places images horizontally, side by side.
- listrow places each image vertically below the previous one.
- tablerow places each image in a separate table row. Use this inside a Word table.
In your Word template, place the foreach code inside a cell or text area where you want the images to appear:
The foreach code placed in a Word template table cell under a Traffic Management heading.
Images inside a group question
When an image question sits inside a group question that allows multiple responses, use a nested foreach. In the examples below, {$id5} is the image question and {$id7} is the group question it sits within.
|
Horizontal group responses, images side by side: {foreach from=$id7 item=_row} {foreach from=$_row.data.id5 item=_picture} {$_picture|insert_image:300:0} {/foreach}
One group response per table row: {tablerow from=$id7 item=_row} {foreach from=$_row.data.id5 item=_picture} {$_picture|insert_image:300:0} {/tablerow}
Vertical group responses: {listrow from=$id7 item=_row} {foreach from=$_row.data.id5 item=_picture} {$_picture|insert_image:300:0}{/listrow} |
- foreach pulls all group responses horizontally.
- tablerow generates a new row for each group question response. Best for table layouts.
- listrow places each group response vertically below the previous one.
Signatures
Use this code for a signature question, replacing {$idX} with your signature question code. The numbers control the width and height of the signature in pixels.
|
{$idX|insert_image:100:50} Example: {$id43|insert_image:100:50} |
- Adjust the width and height values to suit your template layout.
- Unlike photo images, setting a specific height for signatures is usually fine since they have a consistent shape.
Excel templates (.xlsx)
Excel templates require an image placeholder to be embedded in the template before the variable code will work. The placeholder sets the position and dimensions of the output image.
|
Excel image restrictions
|
Single image
Embed a placeholder image in your Excel template at the position where the output image should appear. The dimensions of the placeholder determine the dimensions of the output image in the PDF.
A 300px x 100px placeholder image embedded in the Excel template. The output image will match these dimensions.
After embedding the placeholder, the variable code is handled automatically by Assignar based on the image question code. No additional code is needed in the cell for single images in Excel.
Signatures
Setting up a signature in an Excel template requires two steps: embedding a placeholder image and adding a variable code.
Step 1: Add an image placeholder
Embed an image in your template where you want the signature to appear. The size of the placeholder sets the size of the signature in the output. The placeholder must use the same file format as the signature (JPG or PNG).
An Excel template with a 300px x 100px placeholder image and the variable code {$MyImage|image:1:png} placed in the adjacent cell.
Step 2: Add the variable code
Add the following code anywhere in your template to map the signature to the placeholder image:
|
{$idX|image:1:png} Replace {$idX} with your signature question code. The 1 refers to the image number in the Excel file. Replace png with jpg or jpeg to match your placeholder file type. |
|
Image numbering in Excel
|
Things to know
- Setting height to 0 in the image code preserves the original aspect ratio. Setting a specific height may cause images to appear stretched.
- The Multiple checkbox on an image question must not be ticked when using the single image code in Word, or any image code in Excel.
- In Excel, each placeholder image must be a different file to avoid Assignar treating multiple placeholders as the same image.
- Tablerow requires specific Word table settings to be enabled. See Tablerow, listrow, and foreach in custom printing for setup details.