javabarcodecode39

generate code39 barcode data in java?


I'm trying to generate code39 data. It has some requirement as follows:

/*
       Code 39 Valid data char set:
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (Digits)
            A - Z (Uppercase letters)
            - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus)

       Code 39 extension Valid data char set:
            All ASCII 128 characters
    */
    // Code 39 encodes upper case chars only, for lower case chars, use Code 39 extension
    barcode.setData("123456789012");

Now I want to know if it has a length for the generated data and how to generate it?

Thanks


Solution

  • According to Wikipedia Code 39 is restricted to 43 characters.In order to generate it's encoding data I've used the following code:

    String data=RandomStringUtils.random(20,0,0,true,true,null).toUpperCase();