Databar Expanded and Databar Expanded stacked AI(10)(21)


Hi All,

Can you confirm if the parenthesis sign () can be support in databar AI(10) and AI(21) section? if so how can i pass them in , any escape?

Thank you in advance .



It is not supported. Can you please share a sample in which format you want to pass the parenthesis?


In the AI(10) or 21 from gs1 document the () is acceptable char. we need them in svg format. can we pass the key as binary string.




This issue has been logged into our issue tracking system as BARCODEJAVA-527 for further investigation why parenthesis are not accepted. We will update you as soon as the investigation is complete. Sorry for the inconvenience.


Hi All,

Thank you so much I found out the solution for this issue we can call builder.setBinaryCodeText(codeText);

to pass the (). the barcode image is generated .


I have another weird issue for GS1 Databar expanded.

when I pass the GTIN="(01)00766907146318(21)!"%&’()+,-./0", the barcode can be generated
but when i pass the GTIN="(01)00766907146318(10)123(21)!"%&’()
+,-./0", I can not generate the barcode

Can I know why ? I just need to explain to QA team. Thank you

AI (10) and (21) can accept up to 20 chars.



Can you please share the code which is generating correct barcode for your first GTIN i.e. “(01)00766907146318(21)!”%&’()+,-./0"?

	String GTIN3 = "(01)00766907146318(21)!\"%&'*+,()-./0";
	//String GTIN3 = "(01)00766907146318(11)991020(13)991022(10)12345678901234567890";
	//String GTIN3 = "(01)00766907146318(11)991020(13)991022(17)201112(21)123456123(10)1234567890123456789";
	// limitation length of databar
	//String GTIN3 = "(01)00766907146318(11)991020(13)991022(15)991022(10)12345678901234567890(21)1234567890";
	//String GTIN3 = "(01)00766907146318(11)991020(13)991022(17)201112(10)12345678901234567890(21)123456789";
	//String GTIN3 = "(01)00766907146318(11)991020(13)991022(17)201112(21)12345678901(10)1234567890123456789";
	//String GTIN3 = "(01)00766907146318(11)991020(13)991022(10)12345678901234567890(21)123456789012345678";
	float xdim=0.203f;
	// Generate and save the image to file
	BarCodeBuilder builder = new BarCodeBuilder();
	// Set code text
	byte[] codeText =  GTIN3.getBytes();
	// Set Symbology type
			new Resolution(300, 300, ResolutionMode.Customized));

	short sp = builder.getCodabarStopSymbol();
	short st = builder.getCodabarStartSymbol();

	try {"c:\\temp\\" + xdim *1000 + ".svg", BarCodeImageFormat.Svg);
	} catch (IOException e) {
		// TODO Auto-generated catch block



Thanks for the details. Neither Aspose.BarCode, nor any other barcode generator is accepting the second GTIN shared in your previous post, so there must be some issue with the GTIN. The issue has been logged as BARCODEJAVA-529. Please spare us a little time to investigate the issue and share the exact reason why this GTIN “(01)00766907146318(10)123(21)!”%&’()* +,-./0" is not being accepted.



The reason is that this symbology is capable of encoding up to 74 numberic or 41 alphabetic characters of AI element string data internally represented as a binary number. The first GTIN which is generating the barcode successfully at your end has 35 alphabetic characters. The second GTIN which is throwing exception has a total of 43 alphabetic characters and is not acceptable.

Regarding usage of parenthesis, it should not be used inside the text because it is only a special character for separating AI blocks. So, your sample is encoded like a standard text, not GS1.


But i donot know why this GTIN="(01)00766907146318(13)991012(10)12345678123456789(21)<=>9j?*+,-./"

can be generated correctly. another one String can not .

GTIN1 = “(01)00766907146318(13)991012(10)123456781234567a(21)<=>9j?*+,-./”;

the first one is 66 char already? Ijust what to know what is rule for the limited length so we can put some restrictions for the user entry.

Thank you in advance for any help.

//String GTIN1 = “(01)00766907146318(10)57&uh(21)!><mki757";
//String GTIN1 = "(01)00766907146318(13)991012(10)12345678123456789(21)<=>9j?
String GTIN1 = “(01)00766907146318(13)991012(10)123456781234567a(21)<=>9j?*+,-./”;
float xdim=0.179f;

	// Generate and save the image to file
	BarCodeBuilder builder = new BarCodeBuilder();
	// Set code text
	// Set Symbology type

			new Resolution(300f, 300f, ResolutionMode.Customized));
	try {"c:\\temp\\" + "default" + ".svg", BarCodeImageFormat.Svg);
	} catch (IOException e) {
		// TODO Auto-generated catch block



As per information shared with you earlier,

Capacity: Maximum 74 Numeric/ 41 alphabetic
Please check:

Another thing is that GS1 standard is very complicated as can be seen from its 455 pages specifications.

A short explanation about AI coding is as follow:
String with parentheses is only for human reading. Barcodes contain “internal” data with FNC symbols.

For example:

(01)00766907146318(10)123(21)1234567 (length is 36)
converts to
<FNC1>010076690714631810123<FNC1>211234567 (length is 32)
where <FNC1> is 1 special character and the capacity limit affects only FNC-string.

We hope this clarifies your query now.

Symbol count for the DATABAR_EXPANDED barcode

I total understood the our GS1 spec. the FNC1 should be encoded in the barcode . but i do not understand your implemetation why the (01)00766907146318(13)991012(10)12345678123456789(21)<=>9j?*+,-./ can be generated .

the length should be FNC1+0100766907146318139910121012345678123456789FNC121<=>9j?*+,-./

it is the 58 length . but (01)00766907146318(13)991012(10)123456781234567a(21)<=>9j?*+,-./ can not. it is 58length, even the a conside ascii code 65 it still 59 length.

if both can not be generated it is fine for me. I just need to explain it to qa team.




I think it is not related to the ASCII of character “a”, but the present of “a” itself due to which the limitation of 41 applies as per specifications. Are you able to generate Barcode from it using any other 3rd party BarCode generation tools? If so, please share a reference with us so that we can further investigate it at our end.


Sorry I can not find out other tools can generate this GTIN. but my question is that why the first GTIN=(01)00766907146318(13)991012(10)12345678123456789(21)<=>9j?*+,-./ can be generated it seems to me exceed the 41 limitation.

Thank you in advance for any help.



The issue is already under investigation with issue id: BARCODEJAVA-529. We have further logged your comments against the ticket for consideration and will update you here once some feedback is available in this regard.


Many Thanks,



You are requested to please use the following code sample to generate Databar Expanded Barcode.

BarCodeGenerator generator = new BarCodeGenerator(EncodeTypes.DATABAR_EXPANDED);
String fullPath = path + "BARCODEJAVA529.png";
BufferedImage barcode = generator.generateBarCodeImage();
ImageIO.write(barcode, "PNG", new File(fullPath));
System.out.println("File saved to " + fullPath);
BarCodeReader reader = new BarCodeReader(barcode);
while (