Label with logo

Label with logo

An example of label with a personal logo

The logo is stored in the folder param (name: param/logo.png)

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="objects">
 <fo:root>
 <fo:layout-master-set>
 <fo:simple-page-master master-name="label"
 page-height="5cm" page-width="10cm" margin-left="0.5cm" margin-top="0.5cm" margin-bottom="0cm" margin-right="0.5cm"> 
 <fo:region-body/>
 </fo:simple-page-master>
 </fo:layout-master-set>
 
 <fo:page-sequence master-reference="label">
 <fo:flow flow-name="xsl-region-body"> 
 <fo:block>
 <xsl:apply-templates select="object" />
 </fo:block>

</fo:flow>
 </fo:page-sequence>
 </fo:root>
 </xsl:template>
 <xsl:template match="object">

<fo:table table-layout="fixed" border-collapse="collapse" border-style="none" width="8cm" keep-together.within-page="always">
 <fo:table-column column-width="4cm"/>
 <fo:table-column column-width="4cm" />
 <fo:table-body border-style="none" >
 <fo:table-row>
<fo:table-cell >
<fo:block text-align="center">
 <fo:external-graphic src="../param/logo.png" content-height="scale-to-fit" height="1cm" content-width="4cm" scaling="uniform" />
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><fo:inline font-weight="bold">IRSTEA</fo:inline></fo:block>
</fo:table-cell>
</fo:table-row>
 <fo:table-row>
 <fo:table-cell> 
 <fo:block>
 <fo:external-graphic>
 <xsl:attribute name="src">
 <xsl:value-of select="concat(uid,'.png')" />
 </xsl:attribute>
 <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
 <xsl:attribute name="height">3cm</xsl:attribute>
 <xsl:attribute name="content-width">4cm</xsl:attribute>
 <xsl:attribute name="scaling">uniform</xsl:attribute>
 </fo:external-graphic>
 </fo:block>
 </fo:table-cell>
 <fo:table-cell>
 <fo:block>uid:<fo:inline font-weight="bold"><xsl:value-of select="db"/>:<xsl:value-of select="uid"/></fo:inline></fo:block>
 <fo:block>id:<fo:inline font-weight="bold"><xsl:value-of select="id"/></fo:inline></fo:block>
 <fo:block>prj:<fo:inline font-weight="bold"><xsl:value-of select="prj"/></fo:inline></fo:block>
 <fo:block>clp:<fo:inline font-weight="bold"><xsl:value-of select="clp"/></fo:inline></fo:block>
 <fo:block>cd:<fo:inline font-weight="bold"><xsl:value-of select="cd"/></fo:inline></fo:block>
 </fo:table-cell>
 </fo:table-row>
 </fo:table-body>
 </fo:table>
 <fo:block page-break-after="always"/>

</xsl:template>
</xsl:stylesheet>

Modification date: 16 May 2023 | Publication date: 22 March 2023 | By: Éric Quinton