Free Support Forum -

Minimum barcode size validation


I would like to ask if there is a way to generate barcode image with custom size (getCustomSizeBarCodeImage method) that does not qualify as minimal by getMinimumBarCodeSize() method? We have specific request from our client regarding sizes of some barcode types and in some cases those dimensions do not meet requirements imposed by your product.

Alternatively if there is no option to disable this validation maybe there is a way to adjust single bar width in order to fit into required dimension? Any suggestion would be apprecieated.

We use Aspose.BarCode for Java version 18.3.


Minimum barcode image size depends upon code text length. getMinimumBarCodeSize() is the method exposed to facilitate the user to get minimum possible dimension. Furthermore If you remove margins and set setCodeLocation to None then the image size will be different. Please consider these and try at your end.

Thanks for your reply, @ikram.haq

Yes, I’ve noticed it depends on code text length but I need to use predefined fixed values for barcode images dimensions and it’s not guaranteed that for each generation I will be given code text with the same legth. Hence my question - is it possible to generate barcode image that does not meet minimal barcode size specified by result of getMinimumBarCodeSize() method. In most cases I need to generate smaller images but that raises exception.


No, it is not possible to generate image which does not compliance with minimum dimension required. You defiantly will get runtime exception in case the code text does not fit in custom defined height and width.


What is the reasoning behind imposing size restriction on generated barcodes? I’ve used a few other barcode generators and have’t seen such requirements in theirs implementation hence my curiosity.

Another question - can I set the with of a single bar or is it a fixed value and if so what is it?

And the last one - what is the X dimension (width of code module) for type GS1-128? Specification states that it should not be less than 0.5mm and more than 1,016mm.


This limitation is internal to current implementation of BarCodeBuilder. We are working on improving the barcode generation process. More enhanced, clear and user friendly API will be released soon.

Yes, you can set single bar width of the barcode using property BarCodeBuilder.xDimension. BarCodeBuilder.xDimension is the smallest size of bar in the barcode for all 1D barcodes including GS1-128.

@ikram.haq, could you please specify when can we expect the release?


There is no reliable ETA available for this. We are sorry for the inconvenience.