Click for a Business Review of, Inc., a Barcode Hardware, Software & Services in Tampa FL Contact IDAutomationView your cart in the IDAutomation Store

Pass a Byte Array into Java Components

The following error may occur when passing a byte array directly into the DataToEncode method that expects a string value when using the Java Barcode Components:


The solutions differ depending on the symbology:

  • PDF417: This is only possible with IDAutomation PDF417 Java Products V 4.10 dated October, 2004 or later. When using PDF417, pass the byte array to the binaryCode field of the class library. Make sure to set the processTilde to false and set PDFMode to 0.
    For example:
    PDF417 bc=new PDF417();
    Download a working example of this code here...

  • Data Matrix: When using Data Matrix barcodes, use the code example below to convert the byte array (encodedBytes) into a string that can be encoded in the code field. Make sure to set the encoding to E_BASE256 and processTilde to false.
    DataMatrix bc = new DataMatrix();
    bc.encoding = DataMatrix.E_BASE256;
    String binaryString;
    for (int i=0; i < encodedBytes.length; i++)
        binaryString = Integer.toBinaryString((int)encodedBytes[i]);
        if (binaryString.length() > 8)
        binaryString = binaryString.substring(binaryString.length()-8,binaryString.length());
        bc.code = bc.code + (char) Integer.parseInt(binaryString,2);

    Download a working example of this code here...

 ©Copyright 2015, All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook
Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.