Skip to end of metadata
Go to start of metadata
Contents Summary
  

Working with Image Borders

Aspose.BarCode allows its users to handle everything about barcode image borders, which include setting border style, margins and its width. Let's experience these features one by one.

Border Style

Developers can customize the border style of the barcode image using BorderDashStyle property that is included in all barcode generating classes in Aspose.BarCode. Aspose.BarCode offers some built-in border styles which are contained in an enumeration also named as BorderDashStyle. Developers can select a desired border style from this enumeration and then assign that selected border style to the BorderDashStyle property of the barcode class. The pre-defined border styles in BorderDashStyle enumeration are as follows:

Border Styles

Description

Dash

Specifies a line consisting of dashes

DashDot

Specifies a line consisting of a repeating pattern of dash-dot

DashDotDot

Specifies a line consisting of a repeating pattern of dash-dot-dot

Dot

Specifies a line consisting of dots

Solid

Specifies a solid line

The above described border styles are demonstrated graphically in the figure below:

Pre-defined border styles

Aspose.BarCode for Java does not support Border features.

Margins

Margin is the area between the border and the area captured by bars of the barcode and CodeText. Developers can set the border margins of the barcode image by setting the Margins property found in any barcode class provided by Aspose.BarCode. Margins property takes an instance of MarginsF class that specifies Left, Right, Top and Bottom margin settings for the border. Please note the default settings of border margins are Left=2, Right=2, Top=1 and Bottom=1.

 

Border Width

A very simple but handy feature is to set the border width of the barcode image. The border can be made thick or thin by setting BorderWidth property of the barcode class.

 

Enable Image Border

Developers may also decide whether to show or hide an image border by setting the BorderVisible property of the barcode class to true or false.

 

A complete example to handle borders of the barcode image is given below.

 

Colorize portion of Barcode Image

Normally, barcodes are generated and printed in black and white colors. But, what if it is required to generate a colored barcode?. Keeping this possible requirement in mind, Aspose.BarCode gives free hand to developers to change the colors of:

  • Barcode
  • Code text
  • Barcode Background
  • Barcode Border
  • Caption

All barcode classes ( BarCodeBuilder, BarCodeControl and BarCodeWebControl ) provided by Aspose.BarCode have some common properties that are used to colorize different parts of a barcode as follows:

  • ForeColor property to assign any color to the Barcode
  • CodeTextColor property to assign any color to the Code text of the barcode
  • BackColor property to set the Background color of the barcode
  • BorderColor property to set the Border color of the barcode

Developers can select any desired color and then assign that selected color to any of the properties (ForeColor, CodeTextColor, BackColor or BorderColor) according to their custom requirements. The following code snippet shows you how to
colorize portion of barcode Image.

 

Control Barcode Image Quality

Aspose.BarCode can render anti-aliased barcode images that provide much better quality due to anti-aliasing. The quality of anti-aliased barcode images is more distinguished when barcode is generated with high resolution. All you have to do is to set ImageQuality property (of any barcode class provided by Aspose.BarCode) to any desired pre-defined image quality mode stored in ImageQualityMode enumeration. The pre-defined image quality modes in ImageQualityMode enumeration are listed below:

Image Quality Modes

Description

Default

Specifies simple image rendering

AntiAlias

Specifies Anti-aliased image rendering. Much better quality due to antialiasing but at a higher performance cost

 

Here's an example to set ImageQuality of barcode windows control

Setting BarCodeControl's ImageQuality

Control Bars Filling of 1D Barcodes

Aspose.BarCode supports the new property FilledBars for BarCodeBuilder for generating filled or not filled bars. This property works only with 1D barcodes. Default value is true (filled).

 

Set Barcode Image Margins

It is possible to set barcode image margins using Aspose.BarCode. Margins is the area between the edges of the barcode image and its border. By default, the border of barcode image is visible on the barcode. If the border is shown, the image margin is between the border and the edges of the image. But, if the border is hidden then border margin will not be effected and image margin covers the area between the area captured by bars and the edges of the barcode image. All above concepts about image and border margins can be understood clearly with the help of the figure below:

Setting BarCodeControl's ImageQuality

Developers can set the image margins of the barcode image by setting the Margins property found in any barcode class provided by Aspose.BarCode. Margins property takes an instance of MarginsF class that specifies Left, Right, Top and Bottom margin settings for the barcode image. The default settings of border margins are Left=2, Right=2, Top=1 and Bottom=1.

 

The following picture explains how various settings cooperate together

  1. When AutoSize is set to be true, Margins will control the marginal area around the barcode images and code text. If code text or caption's size exceeds Margins settings, image will enlarge, Margins will increase accordingly.
  1. When AutoSize is set to be false, ImageWidth and ImageHeight will control the marginal area around the barcode images and code text, subsequently, Margins settings will be ignored.

AutoSize : true

AutoSize : False

Rotate Barcode Image

Aspose.BarCode allows developers to rotate the barcode image by setting the RotationAngleF property of the barcode class.

Demonstration of common rotation angles

 

You might set BarCodeBuilders's ImageQuality to AntiAlias to achieve better image quality

Labels
  • No labels