Barcode Functions Print this Topic Previous Page Up One Level Next page

Home >  Engine Information > XSLT and XPath/XQuery Functions > Altova Extension Functions >

Barcode Functions

The XSLT Engine uses third-party Java libraries to create barcodes. Given below are the classes and the public methods used. The classes are packaged in AltovaBarcodeExtension.jar, which is located in the folder <ProgramFilesFolder>\Altova\Common2019\jar.


The Java libraries used are in sub-folders of the folder <ProgramFilesFolder>\Altova\Common2019\jar:


barcode4j\barcode4j.jar  (Website:
zxing\core.jar  (Website:


The license files are also located in the respective folders.


Java virtual machine

In order to be able to use the barcode functions, a Java virtual machine must be available on your machine. The path to the machine is found as noted below.


If you are using an Altova desktop product, the Altova application attempts to detect the path to the Java virtual machine automatically, by reading (in this order): (i) the Windows registry, and (ii) the JAVA_HOME environment variable. You can also add a custom path in the Options dialog of the application; this entry will take priority over any other Java VM path detected automatically.
If you are running an Altova server product on a Windows machine, the path to the Java virtual machine will be read first from the Windows registry; if this is not successful the JAVA_HOME environment variable will be used.
If you are running an Altova server product on a Linux or macOS machine, then make sure that the path to the Java virtual machine is stored in the JAVA_HOME environment variable. The path must point to the jvm.dll file in the \bin\server or \bin\client directory.


The com.altova.extensions.barcode package

The package, com.altova.extensions.barcode, is used to generate most of the barcode types.


The following classes are used:


public class BarcodeWrapper

 static BarcodeWrapper newInstance( String name, String msg, int dpi, int orientation, BarcodePropertyWrapper[] arrProperties )

 double getHeightPlusQuiet()

 double getWidthPlusQuiet()

 org.w3c.dom.Document generateBarcodeSVG()

 byte[] generateBarcodePNG()

 String generateBarcodePngAsHexString()


public class BarcodePropertyWrapper Used to store the barcode properties that will be dynamically set later

 BarcodePropertyWrapper( String methodName, String propertyValue )

 BarcodePropertyWrapper( String methodName, Integer propertyValue )

 BarcodePropertyWrapper( String methodName, Double propertyValue )

 BarcodePropertyWrapper( String methodName, Boolean propertyValue )

 BarcodePropertyWrapper( String methodName, Character propertyValue )

 String getMethodName()

 Object getPropertyValue()


public class AltovaBarcodeClassResolver Registers the class com.altova.extensions.barcode.proxy.zxing.QRCodeBean for the qrcode bean, additionally to the classes registered by the org.krysalis.barcode4j.DefaultBarcodeClassResolver.



The com.altova.extensions.barcode.proxy.zxing package

The package, com.altova.extensions.barcode.proxy.zxing, is used to generate the QRCode barcode type.


The following classes are used:


class QRCodeBean


Extends org.krysalis.barcode4j.impl.AbstractBarcodeBean
Creates an AbstractBarcodeBean interface for


 void generateBarcode(CanvasProvider canvasImp, String msg)

 void setQRErrorCorrectionLevel(QRCodeErrorCorrectionLevel level)

 BarcodeDimension calcDimensions(String msg)

 double getVerticalQuietZone()

 double getBarWidth()


class QRCodeErrorCorrectionLevel Error correction level for the QRCode

 static QRCodeErrorCorrectionLevel byName(String name)

 “L” = ~7% correction

 “M” = ~15% correction

 “H” = ~25% correction

 “Q” = ~30% correction



XSLT example

Given below is an XSLT example showing how barcode functions are used in an XSLT stylesheet.


<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="2.0" xmlns:xsl="" 

   <xsl:output method="html" encoding="UTF-8" indent="yes"/>

   <xsl:template match="/">




            <img alt="barcode" src="{altovaext:get-temp-folder()}barcode.png"/>



         method="text" encoding="base64tobinary" >

         <xsl:variable name="barcodeObject" 
            select="altovaext-barcode:newInstance(&apos;Code39&apos;,string(&apos;some value&apos;), 
            96,0, (altovaext-barcode-property:new( &apos;setModuleWidth&apos;, 25.4 div 96 * 2 ) ) )"/>

         <xsl:value-of select="xs:base64Binary(xs:hexBinary(string(altovaext-barcode:generateBarcodePngAsHexString($barcodeObject)) ))"/>





© 2019 Altova GmbH