Creating Two-dimensional (2D) Barcodes

Creating a Two-dimentional Barcode

The BarCodeAttributes class supports both one-dimensional and two-dimensional barcodes. Creating two-dimensional barcodes is just the same as creating one-dimensional barcodes.

Creating a Pdf417 Barcode

This is a quick example. Read more about creating PDF417 barcodes.

Sample PDF417 barcode

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);

        // width of each module

        b.setYDimension(0.6f);

        // height of each module

        b.setYDimension(1.2f);

        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(

      "this is some test code text. \n Second line \n third line.", "Pdf417")

   )]]>

</imageExpression>

</image>

Creating a DataMatrix Barcode

This is a quick example. Read more about creating DataMatrix barcodes.

Sample DataMatrix barcode

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);

        // width of each module

        b.setXDimension(0.6f);


        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(

      "12345678", "DATAMATRIX")

   )]]>

</imageExpression>

</image>