Image element

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. 

Notes
NOTE: Supported image types are: bmp, png, gif, tif, tiff, jpg, jpeg and svg.

 Here these topics are covered:

  1. How to  insert an image in a template. Both a fixed image and a  dynamic image, where the image is selected from the installed images in InterFormNG2.
  2. How to select an  image found via a URL - both via the file system or via the web.
  3. Insert a  hyperlink for the image, so that the image can be clicked in PDF and HTML output.
  4. How to  resize an image.
  5. How to  rotate an image.
  6. How to  vertically align a fixed positioned image.
  7. Multiple properties of the image can be set via a dynamic Xpath expression in the bottom of the image properties. The position can also be setup via an Xpath expression.
  8. Support for transparent images
  9. Support for PDF/UA output. The section below describes the steps to do for the images if the template is to be used for PDF/UA output.

How to insert an image in a template

An image can be inserted in two ways, if you want to insert a fixed image from the library:

If you click the image icon on the top left of the designer, then you will see the folder system containing the images, from where you can select and drag the image into the result view: 
The other option can be used for fixed images and must be used for dynamic images. For this you click on the image icon in the top middle:  

When you click this icon this window will pop up:

(The same window pops up, if you right click on an image and select 'Image properties')

The fields for the image are these:

Source

If you select Library, then you can select (with the magnifying glass) between the images stored in the library. These images can also be selected dynamically.

If you select URL, then the URL of the image is to be defined e.g. https://www.interform400.com/templates/interform/images/logotype.png.


The URL option should be considered if either you want to use a link to an external image like above - or if you want to select dynamically between MANY images - so many images, that installing them in the library is not an option. Here you should consider an XPath expression to set the path - similar to like described for dynamic images.

 

If possible it is better to refer to installed images as this will improve performance compared to images found via a URL.


If you want to link to a local file, then you can do that with a URL like this:

file:/C:/Users/myuser/Pictures/Myfile.jpg

If you want to refer to an image e.g. in the IFS of an AS400 (from another machine e.g. a Windows PC), then you can use this as the URL in the designer:

file:////<machine ID or IP-address>/apf3812home/Work/Demoimage.JPG

This does require, that the Windows PC has Netserver access to the IFS. You might even need to run the InterFormNG2 under a specific user profile in order to gain access.

 

If you are running InterFormNG2 locally on the IBM i and you want to include a dynamic image from the local IFS, then you can refer to the image like so:

file:/apf3812home/work/Demoimage.jpg

If there is a space in the path, then you need to replace the spaces with %20. You can do that in this way with an XPath expression:

replace('file:/C:/Users/myuser/Pictures/My File.jpg',' ','%20')

You can use a  dynamic image (which e.g. is found dynamically for each customer) in a mail template to track if a specific image has been downloaded as a way to track if an email has been opened.

  

The entry line of the source has two different modes:

Either the image is referenced with a Library path or a URL as above. In the Library mode the magnifying glass opens the list of all images in the library. In URL mode the image is referenced via a URL, so any reachable image can be used.  

 

If you click the 'T' on the right, then the mode is changed to expression, which is described below. At the same time double quotes "" are inserted around the text to make it a valid XPath expression.

 

Placeholder image

In URL mode you can refer to a placeholder image:

 

This placeholder image is then used in the designer only in order to replace the linked image in the URL. You can select the placeholder image from the Library via the magnifying glass on the right and remove the reference to a placeholder image, if you click the trashcan icon on the very right. 

 

In expression mode you can build a dynamic reference to the image the magnifying glass opens an Xpath dialog, which can display the contents of the sample XML file, a list of defined variables and a list of all extra built-in Xpath functions. If you click the icon '< >' on the right, then the mode is change into the fixed mode above. If you e.g., use this Xpath expression with the demo xml file: 

concat("/Intro/image_",/Root/Document[1]/DocumentNo,".jpg")

 then the dynamic image will be:

/Intro/image_1004.jpg

More information about Xpath is found here.

If you want to select a dynamic image, that is found in the installed images, then the source parameter should be Library. If you select URL as the source, then you can also use an XPath expression to refer to an image, that is not installed in InterFormNG2. 

If you want to include a dynamic image via a parameter on an AS400 command, then you should check out the example here.

 

Fallback image

If you include a dynamic image e.g. to include an image of a specific product, that is mentioned on a detail line, then you might not have an image of any product, so you need a way to handle missing images. For missing images you can either choose to include a fallback image or choose to not insert any image at all. This is covered in the section, Fallback image.

  

Base64 image from input XML file

With the functionality mentioned above, you can even extract a base64 image from an input XML file and use that in the output defined in the designer. If you want to do that, then you can define such an image like below:

 

 

In the example above we define an image with the contents of a URL. The data for the barcode is found in the input XML file, that contains the base64 encoded image in the node /Root/CompanyInfo/image:

NG2Image0003

 

In the example above we tell InterFormNG2, that we expect the base64 encoded image to be a jpg image, but if the image is in a different image format, then InterFormNG2 will try to guess the right image format and use that instead.

  1. Hyperlink
    Here you can define a link (URL to be opened) for the image, when a PDF file is created. If the user clicks on the image, then this web site /URL is opened.
  2. Dimensions
    The size of the image. This can either by dynamic or fixed. If the size is fixed, then you can only set a specific height or width of the image. The other will be calculated to keep the ratio between height and width for the resized image.
  3. PositionThe position of the image. The position can be either relative or fixed within the page/container/table in which it is inserted. If the position is fixed, then the rotation can be set freely. The rotation is relative to the page/container/table in which the image is inserted.
  4. Margins
  5. Margins can be only be inserted, when the image is inserted with relative positioning. If fixed positioning is selected the margin settings are not shown, as they are not used.

 

How to select an image found via a URL

If you select URL, then the URL of the image is to be defined e.g. https://www.interform400.com/templates/interform/images/logotype.png.


You refer to image like below:



The URL option should be considered if either you want to use a link to an external image like above - or if you want to select dynamically between MANY images - so many images, that installing them in the library is not an option. Here you should consider an XPath expression to set the path - similar to like described for dynamic images.

 

If possible it is better to refer to installed images as this will improve performance compared to images found via a URL.

Notes
Please note: It is possible to use a special URL extension to refer to images stored in a folder on a Windows Share connection.

If you want to link to a local file, then you can do that with a URL like this:

file:/C:/Users/myuser/Pictures/Myfile.jpg

If you want to refer to an image e.g. in the IFS of an AS400 (from another machine e.g. a Windows PC), then you can use this as the URL in the designer:

file:////<machine ID or IP-address>/apf3812home/Work/Demoimage.JPG


This does require, that the Windows PC has Netserver access to the IFS. You might even need to run the InterFormNG2 under a specific user profile in order to gain access.

 

If you are running InterFormNG2 locally on the IBM i and you want to include a dynamic image from the local IFS, then you can refer to the image like so:

file:/apf3812home/work/Demoimage.jpg

If there is a space in the path, then you need to replace the spaces with %20. You can do that in this way with an XPath expression:

replace('file:/C:/Users/myuser/Pictures/My File.jpg',' ','%20')

You can use a  dynamic image (which e.g. is found dynamically for each customer) in a mail template to track if a specific image has been downloaded as a way to track if an email has been opened.

 

The entry line of the source has two different modes:

Either the image is referenced with a Library path or a URL as above. In the Library mode the magnifying glass opens the list of all images in the library. In URL mode the image is referenced via a URL, so any reachable image can be used.  

 

If you click the 'T' on the right, then the mode is changed to expression, which is described below. At the same time double quotes "" are inserted around the text to make it a valid XPath expression.

Error handling

Below the URL for the image you see an error handling option. (An alternative is described in the section, Fallback image).
You can use this to decide what should happen if the primary file (found via the specified URL) is not found. The possible values are:

1. Show placeholder (default)
If you select this option, then you should also fill out the place holder image e.g. as below:

With this setup InterFormNG2 will show the placeholder image instead, if the image linked to via the URL was not found. In the designer you will need to click the preview icon in order to see the placeholder image. If you select the option 'Show placeholder' without specifying a placeholder image, then you will get a fatal error like below if the primary URL image is not found.

2. Fatal error
This value indicates, that the image linked to via the URL above must be found. If the image it not found, then the rendering will fail with an error indicating that the image could not be found.

3. Warning
If you select this value and the image selected via the URL is not found, then you will see a warning message in the job log, where the missing, referenced image is referred to, but the rendering will proceed and create the output without the image.

4. Ignore
With this value InterFormNG2 will ignore the URL reference to the image, if this image is not found. There will no indication of a problem in the job log (no error message and not even a warning).
Hyperlink for the image

You can assign a hyperlink to an image, so that a user can click the image in HTML and PDF outputs. You can set the hyperlink in the image element like below:


The hyperlink can of course also be set via an Xpath expression - if you click the T icon on the right.


Resize the image

Resizing an image is like resizing any other element:

1.You can drag in the lower right edge of the image to resize it. The ratio between height and width is kept:


2.You can also type in the new size under the Dimensions field of the image:

You can select how you want to define the size via the dimensions mode. Possible values are:

  1. Dynamic width and height based on contents
    This means, that the image size depends on the resolution (DPI) of the template and the number of dots/pixels in both directions of the image. If the resolution e.g. is 300 DPI and the image is 300 dots high and 450 dots wide, then the image will be 1 inch high and 1.5 inch wide. The image size is however limited by the container it is inserted in (because there is not room for the full image), if it is inserted with a dynamic position. The ratio between height and width of the image is kept, even if the image is resized because of a limiting container.
  2.  One fixed dimension
    If you select this, then you can specify either the width or the height of the image. If you enter one of them, then the other is calculated. If you use this option the original ratio between the height and width of the input image is kept.
  3.  Fixed width and fixed height
    Here you state a fixed height and a fixed width of the image. The ratio between the height and width of the image may not be the same as of the input image. You need to calculate appropriate values yourself, if you want to keep this ratio.
How to rotate an image
It is possible to rotate an image. You can do that in two ways:
  1. By rotating the container in which the image is placed.
  2. By rotating the image itself as explained below.

Rotations of containers and images are accumulated, if they are placed within each other. 

To rotate an image without rotating the container in which the text is placed, you first double click on the image element to view the properties and then change the Position mode to 'Fixed position relative to parent container', then you can change the rotation as marked below.



It is recommended to stick with rotations, that are multiples of 90 i.e. 90,180,270 to ensure that the rotation is supported by the printer.

Info
Please note, that by changing the position mode the subsequent elements that are positioned relative will move upwards.


Vertically align a fixed positioned image

It is possible to vertically align a fixed positioned image. You can choose to position the image above, centered or below a reference point.

 

This is setup with these icons, when you edit the properties of the fixed positioned image:

This option is used below. All the images have the same position from the top, but they have a different alignment:



Support for transparent images

Transparent images are supported in InterFormNG2, but the transparency is only supported for PDF output - not the printed output. The requirement is, that the image itself is transparent (prior to installation in InterFormNG2).


Support for PDF/UA
If you want to create output PDF files, that are PDF/UA-1 compliant, then you need to add an alternative text for the image. That is added as below:


The alternate text should be a description of the image. Please notice, that this can also be set as an Xpath expression.
Similar if you also have added a hyperlink for the image (to define a link on the image, that is active in PDF output), then you also need to add an alternate text for this link like below:


    • Related Articles

    • Fallback image

      This article shows one way to implement a fallback image if the URL for the primary image is not found. It is however recommended to use the error handling option on the image element (for the URL option) instead of the setup below. You can include a ...
    • 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 ...
    • 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 ...
    • Table element

      You can use a table element to insert design elements in organized rows and columns. Each cell in the table can be surrounded by a border and/or filled out with a color. You can even create a dynamic table with a row for each detail line in the input ...
    • 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, ...