Using images in document templates: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{#seo: | |||
|title=Using images in document templates | |title=Using images in document templates | ||
|titlemode=append | |titlemode=append | ||
Line 5: | Line 5: | ||
|description=Using images in document templates | |description=Using images in document templates | ||
}}<div style="background-color:#ffcaca; border: 1px solid #fd9292;padding:10px;">In document templates, it is allowed to use images in the formats: '''BMP''', '''JPG''', '''JPEG''' и '''PNG'''.</div> | }}<div style="background-color:#ffcaca; border: 1px solid #fd9292;padding:10px;">In document templates, it is allowed to use images in the formats: '''BMP''', '''JPG''', '''JPEG''' и '''PNG'''.</div> | ||
There are two ways to use images in [[document templates]]: | 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. | *'''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. | *'''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. | 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 == | == 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: | 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: | ||
Line 59: | Line 55: | ||
::<nowiki>{{Task.File.Employee picture::original}}</nowiki> | ::<nowiki>{{Task.File.Employee picture::original}}</nowiki> | ||
== Using a variable linked to a placeholder image == | == 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. | 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. | ||
Line 76: | Line 70: | ||
and in the window that opens, go to the '''Parameters''' tab, where you'll see the '''Name''' field: | and in the window that opens, go to the '''Parameters''' tab, where you'll see the '''Name''' field: | ||
https://s.pfx.so/pf/Sk/JEuxyp.png | https://s.pfx.so/pf/Sk/JEuxyp.png | ||
In the Name field, enter the name of the variable that corresponds to the field containing the image: | In the Name field, enter the name of the variable that corresponds to the field containing the image: | ||
https://s.pfx.so/pf/uB/rzW6Mm.png | https://s.pfx.so/pf/uB/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. | 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: == | == 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. | *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. | *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. | *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 == | == Using the same image multiple times == | ||
Line 98: | Line 86: | ||
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.''' | 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 == | == Useful links == | ||
*[[Inserting all task files into a document]] | *[[Inserting all task files into a document]] |
Revision as of 14:17, 30 October 2024
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:
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:
and in the window that opens, go to the Parameters tab, where you'll see the Name field:
In the Name field, enter the name of the variable that corresponds to the field containing the image:
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