jasper-reportsbarcode4j

Barcode4j UPCA scancode with leading zero


I'm trying to add a barcode to a report using Jasper Reports in UPCA format. My scancodes are strings, but Barcode4j expects a 12 digit Integer. I can convert this to an Integer, but if there is a leading zero, it is lost, and thus my scancode is now 1 digit too short.

So, how can I use the UPCA format with scancodes that have a leading 0 and keep the leading 0?

Barbecue seems to have the same issues, so I don't imagine using it as opposed to Barcode4j will solve this issue.


Solution

  • Well, it all came down to my test data. Using random numbers is what was causing it to fail. When I looked up UPCA examples and used those, then it worked fine. I didn't have to parse it as an Integer either.