2024 Update Rollup 2

Including ImagesPermanent link for this heading

Beside textual metadata also images may be included in a report. Static images can be included directly in the report design whereas dynamic images are defined in the source XML data. There are two ways to include images:

  • folioimages
  • inlineimages

When using the folioimages tag only the object addresses of the images are included in the XML data. When using the inlineimages tag an identifier and the image data itself is included in the XML data.

folioimagesPermanent link for this heading

In order that the images are available when generating the report the XML must contain a folioimages tag, followed by image tags containing the object address of the image object.

Example

<data>
  ...
  <folioimages>
    <image>COO.1.506.1.1002712</image>
    <image>COO.1.506.1.1002713</image>
  </folioimages>
</data>

When generating the report the defined images are available in the shared resource folder. Thus, in the BIRT Report Designer you can define an “Image file in shared resources”.

The following example extends the previous one including an image for each logbook. The example is not self-containing, it just depicts the differences.

Example

app.ducx Object Model Language

objmodel BIRT@1.506
{
  import COOSYSTEM@1.1;
  import FSCWEBCONT@1.1001;


  class Logbook : CompoundObject {
    compound = true;
    common = true;
    string[] logdescription;
    // defines an image for the logbook
    ImageObject logimage;
    unique TripLog[] logtriplogs {
      child = true;
    }
  }
}

app.ducx Use Case Language

usecases BIRT@1.506
{
  import COOSYSTEM@1.1;
  import FSCVAPP@1.1001;
  import FSCVENV@1.1001;
  import FSCVIEW@1.1001;
  import FSCEXPEXT@1.1001;
  import COOMAPI@1.1;
  import FSCACROBAT@1.1;

    

  usecase GenerateData(retval dictionary result) {
    variant LogbookManagement {
      impl = expression {
        result = {
          objname: cooobj.objname
        };
        dictionary[] logbooks;
        dictionary[] logbookids;
        // images from all logbooks
        string[] logimages;
        // provides the necessary folioimages parent
        dictionary folioimages;

        for (Logbook logbook: cooobj.vmlogbooks) {
          logbooks += logbook.GenerateData();
          logbookids += { id: logbook.objaddress };
          // add all logbook images
          logimages += logbook.logimage.objaddress;
        }
        result.SetEntry("logbook", logbooks);
        result.SetEntry("@logbook", logbookids);

        // this dictionary will contain all logbook images
        folioimages = coort.CreateDictionary();
        // add the logbook images
        folioimages.SetEntry("image", logimages);
        // add the folioimages dictionary to the result dictionary
        result.SetEntry("folioimages", folioimages);
      }
    }
    variant Logbook {
      impl = expression {
        result = {
          objname: cooobj.objname,
          logdescription: cooobj.logdescription,
          // in the report the image corresponding to the logbook can be
          // accessed using the object address and file extension

          logimage: cooobj.logimage.objaddress + "." +
           cooobj.logimage.content.contextension
        };
        dictionary[] logtriplogs;
        for (TripLog triplog: cooobj.logtriplogs) {
          logtriplogs += triplog.GenerateData();
        }
        result.SetEntry("logtriplog", logtriplogs);
      }
    }
    variant TripLog {
      impl = expression {
        result = {
          objname: cooobj.objname,
          trlfrom: cooobj.trlfrom,
          trluntil: cooobj.trluntil,
          trlmiles: cooobj.trlmiles
        };
      }
    }
  }
}

The resulting XML looks like this:

Result

<data>
  <objname>Logbook Management</objname>
  <logbook id="COO.1.506.1.1002523">
    <objname>First Logbook</objname>
<logdescription>Description first logbook</logdescription>
       <!-- generated with logimage: cooobj.logimage.objaddress + "." +
            cooobj.logimage.content.contextension

       -->

<logimage>COO.1.506.1.1002712.jpg</logimage>
...
  </logbook>
  ...
  <!-- generated with result.SetEntry("folioimages", folioimages); -->
  <folioimages>
    <image>COO.1.506.1.1002712</image>
    ...
  </folioimages>
</data>

Note: In the Eclipse BIRT Report Designer the images are displayed broken. For testing purposes you can put some image files corresponding to the sample XML data in the shared resources folder of the Eclipse BIRT Report Designer.

inlineimagesPermanent link for this heading

In order that the images are available when generating the report the XML must contain a inlineimages tag, followed by image tags containing the object address of the image object.

Example

<data>
  ...
  <inlineimages>
    <image name="COO.1.506.1.1002712.jpg">/9j/4AAQSk...</image>
    <image name="COO.1.506.1.1002713.jpg">/9j/4AAQSk...</image>
  </inlineimages>
</data>

When generating the report the defined images are available in the shared resource folder. Thus, in the BIRT Report Designer you can define an “Image file in shared resources”.

The following example modifies the previous one including an inline image for each logbook. The example is not self-containing, it just depicts the differences.

Example

app.ducx Object Model Language

objmodel BIRT@1.506
{
  import COOSYSTEM@1.1;
  import FSCWEBCONT@1.1001;


  class Logbook : CompoundObject {
    compound = true;
    common = true;
    string[] logdescription;
    // defines an image for the logbook
    ImageObject logimage;
    unique TripLog[] logtriplogs {
      child = true;
    }
  }
}

app.ducx Use Case Language

usecases BIRT@1.506
{
  import COOSYSTEM@1.1;
  import FSCVAPP@1.1001;
  import FSCVENV@1.1001;
  import FSCVIEW@1.1001;
  import FSCEXPEXT@1.1001;
  import COOMAPI@1.1;
  import FSCACROBAT@1.1;

    

  usecase GenerateData(retval dictionary result) {
    variant LogbookManagement {
      impl = expression {
        result = {
          objname: cooobj.objname
        };
        dictionary[] logbooks;
        dictionary[] logbookids;        

        // images from all logbooks
        string[] logimages;

        // provides the necessary inlineimages parent
       dictionary inlineimages;
        dictionary inlineimagesids;
        string[] inlineimagesbytes;        

        for (Logbook logbook: cooobj.vmlogbooks) {
          logbooks += logbook.GenerateData();
          logbookids += { id: logbook.objaddress };

          // add all logbook images
          logimages += logbook.logimage.objaddress + "." +
            logbook.logimage.content.contextension;

          // the data of the images Base64-encoded  
          inlineimagesbytes +=
            coouser.Base64Encode(logbook.logimage.content.contcontent);
        }
        result.SetEntry("logbook", logbooks);
        result.SetEntry("@logbook", logbookids);        

        // provides the "name" XML attribute for the images
        for (string logimage: logimages) {
          inlineimagesids += { name: logimage };      
        }

        // this dictionary will contain all logbook images
        inlineimages = coort.CreateDictionary();

        // add the logbook images
        inlineimages.SetEntry("image", inlineimagesbytes);
        inlineimages.SetEntry("@image", inlineimagesids);

        // add the inlineimages dictionary to the result dictionary
        result.SetEntry("inlineimages", inlineimages);
      }
    }
    variant Logbook {
      impl = expression {
        result = {
          objname: cooobj.objname,
          logdescription: cooobj.logdescription,
          // in the report the image corresponding to the logbook can be
          // accessed using the object address and file extension

          logimage: cooobj.logimage.objaddress + "." +
           cooobj.logimage.content.contextension
        };
        dictionary[] logtriplogs;
        for (TripLog triplog: cooobj.logtriplogs) {
          logtriplogs += triplog.GenerateData();
        }
        result.SetEntry("logtriplog", logtriplogs);
      }
    }
    variant TripLog {
      impl = expression {
        result = {
          objname: cooobj.objname,
          trlfrom: cooobj.trlfrom,
          trluntil: cooobj.trluntil,
          trlmiles: cooobj.trlmiles
        };
      }
    }
  }
}

The resulting XML looks like this:

Result

<data>
  <objname>Logbook Management</objname>
  <logbook id="COO.1.506.1.1002523">
    <objname>First Logbook</objname>
<logdescription>Description first logbook</logdescription>
       <!-- generated with logimage: cooobj.logimage.objaddress + "." +
            cooobj.logimage.content.contextension

       -->

<logimage>COO.1.506.1.1002712.jpg</logimage>
...
  </logbook>
  ...
  <!-- generated with result.SetEntry("inlineimages", inlineimages); -->
  <inlineimages>
    <image name="COO.1.506.1.1002712.jpg">/9j/4AAQSk...</image>
    ...
  </inlineimages>
</data>