The labels are created using the FOP software, written in Java. Here are the operations performed by the application to generate the labels:

  • for each concerned object (containers or samples associated to a container type, and if the container type is attached to a label model), an image of the QRcode is generated in the temp folder ;
  •  in the temp folder, a file in XML format is generated, containing the information to be printed on the label ;
    a file in XSL format, which contains the orders for creating the label, is also created in the same folder. The content of this file comes from a record from the label table ;
  • the PHP program uses FOP to generate, from the XML file and using the XSL file, a PDF file. One page of the file corresponds to a label (the mechanism used by label printers to separate them).

The configuration of the label template means defining both the content of the information that will be inserted in the QRCODE and the form that the label will take, i.e. the information that will be printed, the format, etc. The label template is then used to print the information on the label. This form uses the XSL syntax understood by FOP.

Defining the contents of the QRcode

QRcode is a standardized two-dimensional barcode format that can store up to 2000 characters in 8 bits.
The principle used in the application is to store the information in JSON format. To limit the size of the barcode, the names of the tags must be as small as possible. Here are the mandatory tags to be systematically inserted in a tag :

Name Description
uid Unique identifier of the object in the database
db Database identifier. It’s the value of APPLI_code parameter

Others informations can be inserted:

Name Description
id Main working identifier
col Collection code, for samples
pn Sampling protocol name
clp Risk code associated to the container
Others codes All secondary identification codes defined in the parameter table Identifier types
Fields used in metadata the codes for the fields used in the metadata description. A label template can only be associated with one metadata type

XSL file configuration

The particular syntax of the XSL file should only be modified while keeping the initial version (copy in a notepad, for example), to avoid losing an operational configuration due to a wrong setting.
Here is a description of the file contents and the fields that can be modified.

File header

It allows you to change the size of the label (maximum width and height). You should only change the page-height and page-width attributes. For margins (margin- attributes), be careful and check in particular that QRcodes are not cropped because of insufficient margins.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
<xsl:output method="xml" indent="yes"/>
<xsl:template match="objects">
<fo:simple-page-master master-name="label"
page-height="5cm" page-width="10cm"
<fo:page-sequence master-reference="label">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="object" />
<xsl:template match="object">

Label format

The content of the tag is described in the form of a table (fo :table tags). The first column contains the QRCode, the second column contains the associated text.
Here, two columns of identical size (4 cm each) are defined.

<fo:table table-layout="fixed" border-collapse="collapse"
border-style="none" width="8cm"
<fo:table-column column-width="4cm"/>
<fo:table-column column-width="4cm" />
<fo:table-body border-style="none" >

The cells (table-cell) are inserted into a row (table-row):


QRcode insertion

The QRcode is inserted in a block. The only information that can be modified is that concerning the
height (height attribute and width (content-width attribute)). Make sure that the height and width
are identical, and do not change any other information.

<xsl:attribute name="src">
<xsl:value-of select="concat(uid,’.png’)" />
<xsl:attribute name="content-height">
<xsl:attribute name="height">4cm</xsl:attribute>
<xsl:attribute name="content-width">4cm</xsl:attribute>
<xsl:attribute name="scaling">uniform</xsl:attribute>

Textual content

Other information is displayed in blocks, with one line per information category.
The label starts here with the establishment (here, IRSTEA), written in bold.

<fo:inline font-weight="bold">

Each piece of information is displayed in a block, including a title (for example, uid), associated with one or more values. Thus, the first line displays on the same line, and in bold (font-weight=”bold” attribute), the database code (&lt.xsl :value-of select=”db”/>) and the UID of the object (&lt.xsl :value-of select=”uid”/>).

<fo:inline font-weight="bold">
<xsl:value-of select="db"/>:
<xsl:value-of select="uid"/></fo:inline>
<fo:inline font-weight="bold">
<xsl:value-of select="id"/></fo:inline>
<fo:inline font-weight="bold">
<xsl:value-of select="prj"/></fo:inline>
<fo:inline font-weight="bold">
<xsl:value-of select="clp"/></fo:inline>

Label end

Once all the information is displayed, the table is closed, and a page break is systematically generated:

<fo:block page-break-after="always"/>

Finally, the XSL file is correctly closed:


It is possible to create labels with different formats, for example by creating several
lines. Remember to close your tags, and make sure they are nested correctly, to avoid any worries.
To go further in the layout, consult the project documentation FOP.