Working with BarCode Text Appearance
Control the appearance of Code text
Aspose.BarCode provides complete control over the appearance of the Code text in the barcode image. Many settings can be applied to the Code text to customize its appearance using CodeTextParameters class properties.
Location of Code text
Aspose.BarCode gives full power to developers to decide whether they want to display Code text or not. Moreover, it is also possible to customize that where to display the CodeText (above or below the barcode) as shown below in the figure.
|All possible locations of Code text on the barcode image|
|All barcode generating classes have a CodeTextParameters.Location property that can accept any pre-defined value stored in CodeLocation enumeration.The pre-defined values in CodeLocation enumeration are listed below.|
|Above||Specifies that the Code text is shown on the top of the bar code|
|Below||Specifies that the Code text is shown on the bottom of the bar code|
|None||Specifies that the Code text is hidden|
Alignment of Code text
The horizontal alignment of the Code text can be configured by making use of CodeTextParameters.Alignment property of the BarcodeGenerator class. The CodeTextParameters.Alignment property accepts any enumerated value in Aspose.BarCode.Generation.TextAlignment enumeration (which is a part of the Microsoft .NET Framework). The pre-defined values in StringAlignment enumeration are listed below
|Center||Specifies that text is aligned in the center of the layout rectangle|
|Left||Specifies that text is aligned Left from the original position of the layout rectangle.|
|Right||Specifies the text to be aligned on the right of the layout.|
Color of CodeText
Developers who want to add colors to their barcodes may also change the color of CodeText. Setting the CodeTextParameters.Color property can change the color of the Code text as demonstrated below in a code snippet.
Set CodeText Font Family Name and Size
Setting the CodeTextParameters.Font property to any font family name and its size of the Code text as demonstrated below in a code snippet.
Space between Code text & Barcode
You saw above in the barcode image that the default gap between the barcode and Code text is very small. Developers can increase/decrease the space (gap) between the barcode and Code text by setting the CodeTextParameters.Space property. The following code snippet shows you how to space between code text and Barcode.
A complete example is given below that combines all possible format settings that can be applied to the CodeText to control its appearance.