Using images in document templates

From Planfix
Revision as of 14:19, 30 October 2024 by Dmitri (talk | contribs)
Jump to: navigation, search
In document templates, it is allowed to use images in the formats: BMP, JPG, JPEG и PNG.

There are two ways to use images in document templates:

  • Statically - images are placed in document templates, and they are displayed in each template-generated document exactly as they were placed in the template.
  • Dynamically - images are linked using a File variable, and in each template-generated document the variable is replaced with the image corresponding to the variable at the given time.

To place a dynamic image in a template, you can use a variable with additional parameters or a variable linked to a placeholder image, which determines the size and location of the image in the final document. Both options are outlined below.

Using a variable with additional parameters

In general, to insert an image into a document template, simply add the name of the variable in the desired location (line, cell) of the template, which in each document created will contain the corresponding image file: ZRhtiY.png


The following parameters are used to set the size and position of the image in the final file:

  • For MS Word templates, you can explicitly set the size of the inserted image.

Variable syntax:

{{VariableName::SIZE_X_AXISxSIZE_Y_AXIS}}

Example of using the variable with this parameter:

{{Task.File.Employee picture::200x300}}
  • For MS Word templates, you can explicitly select the option to wrap the image with text. The Wrapping parameter of the variable is used in this case:
Example:
{{System.File::50x50;wrapping=around frame}}
{{System.File::50x50;wrapping=before text}}
{{System.File::50x50;wrapping=up and down}}
Format used:
  • the variable name is added before the "::" separator (two colons);
  • 50x50 is the width x height of the image in the template-generated document;
  • wrapping - selects the wrapping option.

Please note: in the examples above, two parameters are used at once, separated by a semicolon: the image size and text wrapping around the image.

  • For MS Word templates, the MaxHeight and MaxWidth attributes are also available. When one of these attributes is used, the other will be set proportionally to it in the final file.
Example of using the variable with an additional attribute:
{{System.File::MaxWidth=150}}
Result: the image inserted in the resulting document will have a width of 150 pixels and a height adjusted proportionally.
  • In MS Excel templates, images by default "fill" the cell that contains the variable, so the size and proportions will be determined by the size of the cell designated for the image. Merged cells can be used.
To insert an image in its original size, use the "original" attribute. Example of using the variable with this attribute:
{{Task.File.Employee picture::original}}

Using a variable linked to a placeholder image

With this option, a temporary placeholder image is inserted into the document template, which determines the size and position of the image in the final file. This option doesn't require any parameters, since the image settings can be configured "visually," by moving the placeholder image around in the document template and resizing it as desired. A placeholder image can be linked to a variable by setting the variable as the image name in the document template.


To use this option, you must:

  • Open the document template in LibreOffice
  • Paste the image into the file and resize/position it as needed.
  • Right-click the image and select:
    • for Excel templates, Name (see example)
    • for Word templates, Properties:

ls5jfX.png


and in the window that opens, go to the Parameters tab, where you'll see the Name field: JEuxyp.png

In the Name field, enter the name of the variable that corresponds to the field containing the image: rzW6Mm.png

When creating a document using a template designed in this way, the image will appear in the place you specified, relative to other elements in the template.

Useful information for this method:

  • When creating a document using a template, the image in the template is replaced with the image uploaded to the field specified in the name. Therefore, it doesn't matter what image you add to the template file — it's just a placeholder for the image that will be added to the final document.
  • If the name of the image in the template file contains the name of a non-existent field, or if no image is entered into the name field, the resulting file will not contain an image.
  • When creating a document, an image of the size specified in the template will be inserted. This means that if the seal image in your template is 3"x3" but the actual size of the image uploaded to the "Seal" general field is 2"x2", the image will be stretched to 3"x3" in the final file.

Using the same image multiple times

If you need to insert the same image (such as a seal or signature) multiple times in one document template, use a variable with an additional parameter. For example:

{{General.Print::Tag1}}

where the Tag1 parameter is any text unique each time the variable is used in the template (such as Tag1, Tag2, etc.).

This additional parameter, which is added after the "::" symbols (two colons), can be used both in a variable with additional parameters or in a variable linked to a placeholder image.

Useful links


Go To