Manage Barcode Parameters

This article describes how to manage settings provided by Aspose.BarCode for PHP via Java to adjust barcode measurement units (millimeters, inches, points, or pixels) and barcode image resolution.


Cartesian coordinate systems use coordinates of pixels or drawable objects to represent image data for raster or vector images. To link these coordinates to real-world measurement units, such as millimeters or inches, Aspose.BarCode for PHP via Java includes a special class called Unit. Class Unit provides various functions that serve to convert barcode size values defined in pixels, millimeters, inches, or points to any of the supported measurement units automatically. In this way, the size of elements in real-world measurement units can be converted into pixels to generate barcode images.

Measuring Barcode Size in Various Units

Class Unit allows developers to set measurement units for barcode parameters and can be modified using functions of class BarcodeParameters, such as setBarCodeHeight (Unit $value), setBarCodeWidth (Unit $value), and setXDimension (Unit $value). Aspose.BarCode for PHP via Java determines measurement units in the GraphicsUnit enum. Class Unit can be used to convert measurement units into the desired ones: Millimeters, Pixels, Inches, Point (1/72 inch), or Document (1/300 inch). By default, Millimeters are used as size measurement units.

Barcode labels created using various unit settings are shown below.

Size Units Pixels Millimeters

Image Resolution

Aspose.BarCode for PHP via Java allows developers to customize barcode image resolution settings using class Unit. This class includes the setPixels (float $value) function to convert all non-pixel size measurements into digital coordinates in pixels. To convert size values into requested supported untis, the following functions need to be used: setInches (float $value), setMillimeters (float $value), setDocument (float $value), setPoint (float $value), and setPixels (float $value).

Barcode images with different resolution settings are given below.

Resolution Is Set to 96 dpi Is Set to 300 dpi