Fallback image

Fallback image

You can include a dynamic image in InterFormNG2 by e.g. concatenating fixed strings with dynamic information from the input file e.g. like so:

 

NG2Fallback0001

 

The Xpath expression above:

concat('file:/D:/images/',./DocumentNo,'.jpg')

 

- builds the path to the image with the initial string: file:/D/images/ and the ending string: .jpg. In the middle we insert the contents of the DocumentNo subnode of the currently selected node in the input XML file. If the DocumentNo node e.g. has the value 1001, then this expression will try to use the image in D:/images/1001.jpg.

 

If this image file does not exist, then the rendering will stop with an error.

 

It is possible to verify if the image file exist and decide to insert another (or no) image instead, if the primary image does not exist.

 

If you want to do that, then you can use the ng:fileExist() function to verify if the image file exists or not.

A solution could look like this:

 

NG2Fallback0002

 

In the example above we test if the image file exist: If it does exist, then we insert the dynamic image concat('file:/D:/images/',./DocumentNo,'.jpg'), but if the image does not exist, then the image /Intro/demologo_C.jpg is inserted instead.

 

Each element is shown below:

 

The select element:

 

NG2Fallback0003

The dynamic image:

 

NG2Fallback0004

 

The fixed fallback image:

 

NG2Fallback0005

 

    • Related Articles

    • Image element

      It is possible to insert images in InterFormNG2. The image can be either a fixed image found in the library or you can refer to the image via a URL. The related icon is this: Install and upload of images is covered in the Library section. Supported ...
    • Tenant image

      If you have an installation with multiple tenants, then it can be a good idea to add an image for each tenant in order to quickly identify the tenant. If you attach an image for the tenant, then the tenant overview can look like this: Above you can ...
    • PDF page to image

      The workflow component, PDF page to image (of the type, Create document) can be used for converting a single page of a PDF file into an image. A prerequisite is, that the PDF file is loaded into the payload. You can consider the workflow component, ...
    • Include an image from an attachment in an AS400 command

      There are several ways to use a dynamic image in a template, but if you use an AS400 command, then you can also include an image as an attachment in the command, IFORMNG2/NG2CMD. Here is an example of how that can be done: On the command you can ...
    • PDF to images XML

      The workflow component, PDF to images XML (of the type, Create document) can be used for converting a single page of a PDF file into an image. A prerequisite is, that the PDF file is loaded into the payload. The component takes a PDF and renders a ...