Free Support Forum -

BarCodeBuilder getCustomSizeBarCodeImage


i have to generate un BarCode :

BarCodeBuilder builder = new BarCodeBuilder();
builder.setCodeText(“Text exemple”);
BufferedImage img2 = builder.getCustomSizeBarCodeImage(new Dimension( 50, 50 ), false);

But it gives this error “Customize wanted is outside the limits”

How can one specify the dimension and what is the value that should not be exceeded ??

If I want to change it GraphicsUnit GraphicsUnit.Millimeter What is the value of the height and width that should not be exceeded ?

How does this methode work fonctiongetCustomSizeBarCodeImage ?

thank you for your help


As you are using Aspose.BarCode APIs, so you have posted your query in the wrong forum. I am now moving your thread to respective forum and one of my fellow colleagues from Aspose.BarCode team will help you soon there.

Thank you.
Hi Jihane,

Thank you for your inquiry.

This is to update you that you can adjust barcode image size and can set unit of the barcode image through code. There is no implicit/default restriction on maximum height & width except if there is any in the specification e.g. Code 128.

Furthermore we are unable to reproduce the issue at our end. We are attaching the sample output barcode image and sample code for your reference.

// Generate the bar code
BarCodeBuilder builder = new BarCodeBuilder();
// Set symbology type
// Set the code text
// Set the code text location
// Set graphics unit
// Set margins
// Get BufferedImage with exact bar code only
java.awt.image.BufferedImage img = builder.getOnlyBarCodeImage();
// Allows to set size for whole picture with bar code inside
java.awt.image.BufferedImage tt = builder.getCustomSizeBarCodeImage(new java.awt.Dimension(img.getWidth() * 50, img.getHeight() * 50), false);
// Saving the buffered image outputfile = new"custombarcode.png");
javax.imageio.ImageIO.write(tt, "png", outputfile);

Follow the links for details on custom width, barcode image unit size etc:

Hope that above information helps you to generate the barcode image of custom size. Feel free to contact us in case of any query or comments along with your sample code project demonstrating the issue and details about what is expected as output.