Hiding Codetext Too Long to Display

Programming Sample

The following example shows how to hide the barcode codetext.

A barcode with hidden codetext

todo:image_alt_text

Java

 public class MyAttributes

{

    public static BarCodeAttributes Create(String text, String symbology)

    {

        BarCodeAttributes b = new BarCodeAttributes();

        b.setCodeText(text);

        b.setSymbology(symbology);

        b.setCodeTextVisible(false);

        return b;

    }

}

JRXML

 <image hAlign="Center">

<reportElement x="0" y="600"  width="500" height="250" />

<imageExpression class="net.sf.jasperreports.engine.JRRenderable">

   <![CDATA[new com.aspose.barcode.jr.BarCodeRenderer(MyAttributes.Create(

      "The quick brown fox jumps over the lazy dog\n The quick brown fox jumps over the lazy dog\n", "DATAMATRIX")

   )]]>

</imageExpression>

</image>

The following example shows how to reduce the codetext’s font size to save space.

A barcode with smaller codetext

todo:image_alt_text

Java

 public class MyAttributes

{

    public static BarCodeAttributes Create(String text, String symbology)

    {

        BarCodeAttributes b = new BarCodeAttributes();

        b.setCodeText(text);

        b.setSymbology(symbology);

        b.setCodeTextVisible(false);

        b.setCodeTextFont(new Font("Serif", Font.BOLD + Font.ITALIC, 20));

        return b;

    }

}

JRXML

 <image hAlign="Center">

<reportElement x="0" y="600"  width="500" height="250" />

<imageExpression class="net.sf.jasperreports.engine.JRRenderable">

   <![CDATA[new com.aspose.barcode.jr.BarCodeRenderer(MyAttributes.Create(

      "The quick brown fox jumps over the lazy dog\n The quick brown fox jumps over the lazy dog\n", "DATAMATRIX")

   )]]>

</imageExpression>

</image>