10. The barcodes and dynamic images
The personCard.xre example in the database which shows how to:
dynamically select an image
This example creates a personal card with the name and address of a
person together with the photo and a barcode which encodes the name of the
person. The input file is a XML file with a list of persons and their
information, the schema of the XML file is very simple:
The card has been split in 4 columns, the first one contains the photo
and the last one contains the barcodes. These are the 2 objects we are
The image object could be a static image file if you enter a file name
in the image field, however in this example we want to
select a different image for each person (the photo), so we use the xpath
field and enter the value concat('examples/barcodes/foto_',id,'.PNG').
This expression concatenates the 3 values:
id of a person
Since one of the persons has the id 12345 the result for that person
will be examples/barcodes/foto_12345.jpg. So that
is the file that will be used as photo for that person.
Note that we used the id instead of /list/person/idin theconcat function. Since the XMLNode
of the detail area (the card) is/list/person,
we have to use the valueidto find the
correct value for the current person.
The barcode is the second interesting object in this example. When you
add a barcode to your document the barcode type selection window will
popup. At this point you have to decide if it will be a 1D barcode (e.g.
EAN or Code128) or a 2D barcode (Datamatrix, PDF417 ...).
Once the barcode is in your document you can distinguish 2 kind of
In the Data section you can find properties which are common to all
barcodes types. These are:
XPath: as with other objects this is the location in
the XML document where the information for the barcode can be
found. This is the information to be encoded in the
barcode, in our example the name of the person.
Binary base64: this is required if you are going to
encode binary data. In this case the XML document must contain
base64 encoded binary data and the xpath field must point
to a XML node which contains Base64 encoded data.
Process tilde: if true the tilde character (~) will be
processed accordingly. Please refer to the specific barcode
documentation (see link below).
In the Format section the barcode type specific properties are
located. In this Datamatrix example, you can see the datamatrix
encoding and format properties. You
can find more information about the barcode specific properties here http://www.java4less.com/barcodes/barcodes.php?info=guide