Picture in Word
Just like text, in some cases you might want to have pictures in your documents based on certain conditions. In the Studio, this can be done by making use of the picture fragment functionality. First, add any pictures you want to have in your Word template. Then, by making use of the Picture fragment you can replace the pictures in Word depending on the rules you make in your model. Below, an example is given , based on the Word template presented in the document assembly intro.
The first step is to give the image a title.
This is done so you can refer to it.
By selecting the properties of the picture in Word, you can add a title. In English, right-click the image and select
Format picture, in Dutch, select
Then, navigate to the correct tab and change the title:
We have called the picture “berkeley_bridge_logo”, but you can use any name.
Just make sure it is a clear name.
If you have added this document to your model, you can go to
Layout > Picture fragment.
This opens the following dialog;
In the condition field you can add a condition like you normally do. If you don’t know how to use conditions, please take a look at the documentation on conditions.
In ‘Existing picture in document’ there is a drop-down menu. If you open this menu, the Studio will look at all the documents that are created by the model and search them for pictures. If the picture has a title, it will show it, otherwise it shows just the (file)name of the picture. In this example, ‘employee female’ is found in a document called ‘arbeidsovereenkomst.docx’.
In the drop-down ‘Replace with this picture’, the first option is <delete picture>. This deletes the image from the document if the condition is empty or met.
If you want to replace the picture, you can press the ‘…’ button, and select a picture from your hard drive.
If you do this, the Studio will copy this picture to a sub folder <modelname>_images.
The drop-down menu will show all the pictures you have added. If you have selected the picture, just press
This works just like text fragments, so the picture fragment must be used before you create the document.
Again, the replacement will only happen if the condition is empty or met.
You are also able to upload a picture and used it in a document, this could for example be a signature. However, this is only possible if we run the model on an actual server. For this you need a document and a model, both of these links together are an example of how picture uploading could be done.
In this model there are three nodes that are important. These nodes are signature, collect and document.
The first node, signature, contains a text interface and some metadata. The metadata is dependend on the used presentation layer, this example shows a lot of possibilities. The function setmetadata has two values, a name and a value. The value starts with ‘uploads.’ and then an id, in this case ‘0’. After that we have the property name. For instance uploads.0.mimetypes, setting it to ‘.png’. This means only .png files (pictures) can be uploaded to the server. The uploaded file can also be tagged, using uploads.0.tags.ID.propertyname. In this example a tag 0 is created with type ‘constant’, name ‘type’ and value ‘signature’.
Next is the collect node, what this does is look at all the files that are part of the current model and see if it can find a file with the tag ‘signature’, as defined in the signature-node. If this file is found then the name of that file is saved in the variabele picture. By using pictureoutput, the picture ‘signature’ is set on that filename.
The document node is built the same way we are used to, except in the picture.docx file we need to describe the object picture. We give the description the text “signature” and afterwards the picture you upload will appear instead of the picture that is now there. You can access this description by pressing the right button on your mouse and selecting “Edit alt text” in your word document.