2D Datamatrix barcode

Hi,

We have created 2D Datamatrix barcode but the height and width is not equal , is it possible to have a square Datamatrix barcode which all four sides are equal . Please provide the solution at the earliest.

Thanks

Deepa

Hi Deepa,


Thank you for using Aspose products.

With Aspose.BarCode for Java, you can set the image size to some specific size. If the Height and Width is same then the barcode image is square shaped. Please check the below source for you reference.

Java

BarCodeBuilder builder = new BarCodeBuilder();

builder.setSymbologyType(Symbology.DataMatrix);

builder.setCodeText(“AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz”);

builder.setCodeLocation(CodeLocation.NONE);


//Set Width
builder.setImageWidth(100);

//Set Height
builder.setImageHeight(100);
//Set AutoSize to False
builder.setAutoSize(false);

builder.save(“output.png”);

Hi,

Thanks for your reply.

Can you tell me 100 which you have set as height , is this in Pixel/inches/milimeters ?

Thanks

Deepa

Hi Deepa,


Thank you for writing back.

By default the dimensions are in Pixels. Although you can change the measuring unit by setting the Graphic Unit for BarCodeBuilder. Please check the below sample code for your reference.

Java

builder.setGraphicsUnit(com.aspose.barcode.GraphicsUnit.Millimeter);

Hi,

I tried to set barcode image height and width to 144 pixels , but I see that the image size has not changed . If I set xdimension and ydimension using setxDimension and setyDimension to 1.2 then i see the image size changes . Please let me know for what these methods to set the dimension x and y are used .My code is as below:

barCodeBuild.setxDimension(1.2f);

barCodeBuild.setyDimension(1.2f);

barCodeBuild.setCodeTextColor(Color.WHITE);

barCodeBuild.setCodeText(inputXMLData);

barCodeBuild.setCodeLocation(CodeLocation.NONE); //Set Width

barCodeBuild.setImageWidth(144); //Set Height

barCodeBuild.setImageHeight(144);

Thanks

Deepa

Hi Deepa,

Thank you for writing back.

Please note, in order to control the image size by explicitly specifying the height and the width of the image, you also need to set the BarCodeBuilder.setAutoSize() to false.

Below are some related articles for your reference,

Hi,

Thanks for your reply.

I have one more requirement , how can we embed a 1 bit barcode TIFF image into JSP or HTML page ?

Please provide me the solution , Thanks in advance.

Thanks

Deepa

Hi Deepa,


Thank you for writing back.

I am afraid, currently Aspose.BarCode for Java component can only save the generated barcode symbol to Tiff 32 Bits Per Pixel (32bpp) image format.

Regards,