BarcodeOptions Class
Contains barcode options.
Declaration
public abstract class BarcodeOptions extends JavaObject
Remarks
Refer to the following help topic for additional information: Barcode Options.
Inherited Members
Inheritance
BarcodeOptions()
Initializes a new instance of the BarcodeOptions class.
Declaration
public BarcodeOptions()
Methods
clone() Method
Creates a copy of the current object.
Declaration
public BarcodeOptions clone()
Returns
| Type | Description |
|---|---|
BarcodeOptions |
The |
getBackColor() Method
Gets the background color of a barcode image.
Declaration
public Color getBackColor()
Returns
| Type | Description |
|---|---|
| Color | The image background color. |
getBarHeight() Method
Gets the height of bars in a barcode.
Declaration
public float getBarHeight()
Returns
| Type | Description |
|---|---|
| float | The bar height in current units. |
Remarks
The getBarHeight() method returns the configured bar height. Use setBarHeight(float) to reduce barcode height and preserve barcode width.
Note
getBarHeight() and setBarHeight(float) methods do not apply to 2-D and Data Bar barcodes.
getBorderColor() Method
Gets the border color of the barcode image.
Declaration
public Color getBorderColor()
Returns
| Type | Description |
|---|---|
| Color | The border color. |
Remarks
The getBorderColor() method returns the border color of the barcode image. Use setBorderWidth(float) to specify the border width.
getBorderDashStyle() Method
Gets the dash style for the barcode border.
Declaration
public BorderDashStyle getBorderDashStyle()
Returns
| Type | Description |
|---|---|
| BorderDashStyle | The barcode border’s dash style. |
getBorderStyle() Method
Gets the barcode style.
Declaration
public BorderStyle getBorderStyle()
Returns
| Type | Description |
|---|---|
| BorderStyle | The barcode style. |
getBorderWidth() Method
Returns the border width of the bar code image.
Declaration
public float getBorderWidth()
Returns
| Type | Description |
|---|---|
| float | The border width, measured in units specified by setUnit(DXGraphicsUnit value) |
Remarks
If the getBorderWidth() method returns 0, the barcode does not have the border.
getCodeTextHorizontalAlignment() Method
Gets the horizontal alignment of the bar code text within the bar code image.
Declaration
public DXStringAlignment getCodeTextHorizontalAlignment()
Returns
| Type | Description |
|---|---|
| DXStringAlignment | An enumeration value that indicates the horizontal alignment type. |
getCodeTextVerticalAlignment() Method
Gets the vertical alignment of the bar code text within the bar code image.
Declaration
public DXStringAlignment getCodeTextVerticalAlignment()
Returns
| Type | Description |
|---|---|
| DXStringAlignment | The vertical alignment type. |
getDpi() Method
Gets the dpi value used to render the bar code.
Declaration
public float getDpi()
Returns
| Type | Description |
|---|---|
| float | The dpi value used to create the bar code image. |
getFooter() Method
Gets the footer label for the barcode.
Declaration
public BarcodeLabel getFooter()
Returns
| Type | Description |
|---|---|
| BarcodeLabel | The footer label displayed below the barcode. |
getForeColor() Method
Gets the bar’s color on the barcode image.
Declaration
public Color getForeColor()
Returns
| Type | Description |
|---|---|
| Color | The bar’s color. |
getHeader() Method
Gets the header label for the barcode.
Declaration
public BarcodeLabel getHeader()
Returns
| Type | Description |
|---|---|
| BarcodeLabel | The header label displayed above the barcode. |
getHeight() Method
Gets the barcode height, in pixels.
Declaration
public float getHeight()
Returns
| Type | Description |
|---|---|
| float | The barcode height. |
getMargin() Method
Gets bar code image margins.
Declaration
public Padding getMargin()
Returns
| Type | Description |
|---|---|
| Padding | Margin widths for a bar code image. |
getModuleSize() Method
Gets the width of the narrowest bar or space in the bar code.
Declaration
public float getModuleSize()
Returns
| Type | Description |
|---|---|
| float | The width of the narrowest bar or space. |
getPadding() Method
Gets bar code image paddings.
Declaration
public Padding getPadding()
Returns
| Type | Description |
|---|---|
| Padding | A Padding object that contains padding settings. |
Remarks
The getPadding() method returns the space between the barcode and the inner edges of the frame. Use setBorderWidth(float) and setBorderColor(Color) methods to display the frame border and specify its color.
getRightToLeft() Method
Gets whether the barcode text is rendered from right to left.
Declaration
public boolean getRightToLeft()
Returns
| Type | Description |
|---|---|
| boolean |
|
getRotationAngle() Method
Gets the number of degrees the bar code is rotated around the z-axis.
Declaration
public float getRotationAngle()
Returns
| Type | Description |
|---|---|
| float | The number of degrees. |
Remarks
A positive value indicates clockwise rotation, a negative value indicates counterclockwise rotation.
getShowText() Method
Indicates whether the code text is shown.
Declaration
public boolean getShowText()
Returns
| Type | Description |
|---|---|
| boolean |
|
getSides() Method
Gets barcode sides that display the border.
Declaration
public BorderSide getSides()
Returns
| Type | Description |
|---|---|
| BorderSide | Barcode sides with the border. |
getSizeMode() Method
Gets how the control applies the specified width and height to the barcode.
Declaration
public SizeMode getSizeMode()
Returns
| Type | Description |
|---|---|
| SizeMode | A SizeMode enumeration value. |
getTextFont() Method
Gets the font used to draw barcode text.
Declaration
public DXFont getTextFont()
Returns
| Type | Description |
|---|---|
| DXFont | The font used to draw barcode text. |
getTextRenderingHint() Method
Gets the text rendering quality.
Declaration
public DXTextRenderingHint getTextRenderingHint()
Returns
| Type | Description |
|---|---|
| DXTextRenderingHint | The text rendering quality. |
getUnit() Method
Gets the unit of measurement for bar code settings.
Declaration
public DXGraphicsUnit getUnit()
Returns
| Type | Description |
|---|---|
| DXGraphicsUnit | An enumeration value that indicates the measurement units. |
getWidth() Method
Gets the barcode width, in pixels
Declaration
public float getWidth()
Returns
| Type | Description |
|---|---|
| float | The barcode width. |
getWordWrap() Method
Gets whether barcode text wraps if it overflows the barcode width.
Declaration
public boolean getWordWrap()
Returns
| Type | Description |
|---|---|
| boolean |
|
setBackColor(Color value) Method
Sets the background color of a barcode image.
Declaration
public void setBackColor(Color value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | Color | The image background color. |
setBarHeight(float value) Method
Sets the height of bars in a barcode.
Declaration
public void setBarHeight(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The bar height in current units. |
Remarks
Use setBarHeight(float) to reduce barcode height and preserve barcode width. Keep enough height to preserve scanability.
Note
The getBarHeight() and setBarHeight(float) methods do not apply to 2-D and Data Bar barcodes.
setBorderColor(Color value) Method
Sets the border color of the barcode image.
Declaration
public void setBorderColor(Color value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | Color | The border color. |
Remarks
The setBorderColor(Color) method specifies the border color of the barcode image. Use setBorderWidth(float) to specify the border width.
setBorderDashStyle(BorderDashStyle value) Method
Sets the dash style for the barcode border.
Declaration
public void setBorderDashStyle(BorderDashStyle value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | BorderDashStyle | The barcode border’s dash style. |
setBorderStyle(BorderStyle value) Method
Sets the barcode style.
Declaration
public void setBorderStyle(BorderStyle value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | BorderStyle | The barcode style. |
setBorderWidth(float value) Method
Specifies the border width of the bar code image.
Declaration
public void setBorderWidth(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The border width, measured in units specified by the com.setUnit(DXGraphicsUnit value) method. |
setCodeTextHorizontalAlignment(DXStringAlignment value) Method
Sets the horizontal alignment of the bar code text within the bar code image.
Declaration
public void setCodeTextHorizontalAlignment(DXStringAlignment value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | DXStringAlignment | An enumeration value that indicates the horizontal alignment type. |
setCodeTextVerticalAlignment(DXStringAlignment value) Method
Sets the vertical alignment of the bar code text within the bar code image.
Declaration
public void setCodeTextVerticalAlignment(DXStringAlignment value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | DXStringAlignment | The vertical alignment type. |
setDpi(float value) Method
Sets the dpi value used to render the bar code.
Declaration
public void setDpi(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The dpi value used to create the bar code image. |
setFooter(BarcodeLabel value) Method
Sets the footer label for the barcode.
Declaration
public void setFooter(BarcodeLabel value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | BarcodeLabel | The footer label displayed below the barcode. |
Remarks
Use the BarcodeLabel class to customize the appearance and layout of barcode labels. A label can display text above (header) or below (footer) the barcode and supports the following settings:
- Text content
- Font and text color
- Text alignment
- Padding
- Visibility
Refer to the following help topic for additional information and examples: Barcode Header and Footer.
setForeColor(Color value) Method
Sets the bar’s color on the barcode image.
Declaration
public void setForeColor(Color value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | Color | The bar’s color. |
setHeader(BarcodeLabel value) Method
Sets the header label for the barcode.
Declaration
public void setHeader(BarcodeLabel value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | BarcodeLabel | The header label displayed above the barcode. |
Remarks
Use the BarcodeLabel class to customize the appearance and layout of barcode labels. A label can display text above (header) or below (footer) the barcode and supports the following settings:
- Text content
- Font and text color
- Text alignment
- Padding
- Visibility
Refer to the following help topic for additional information and examples: Barcode Header and Footer.
setHeight(float value) Method
Sets the barcode height, in pixels.
Declaration
public void setHeight(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The barcode height. |
setMargin(Padding value) Method
Sets bar code image margins.
Declaration
public void setMargin(Padding value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | Padding | Margin widths for a bar code image. |
setModuleSize(float value) Method
Sets the width of the narrowest bar or space in the bar code.
Declaration
public void setModuleSize(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The width of the narrowest bar or space. |
setPadding(Padding value) Method
Sets bar code image paddings.
Declaration
public void setPadding(Padding value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | Padding | A Padding object that contains padding settings. |
Remarks
Paddings in a barcode image are the spaces between the barcode and the inner edges of the frame that contains it. Use setBorderWidth(float value) and setBorderColor(Color value) to display the frame border.
setRightToLeft(boolean value) Method
Sets whether the barcode text is rendered from right to left.
Declaration
public void setRightToLeft(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
setRotationAngle(float value) Method
Sets the number of degrees the bar code is rotated around the z-axis.
Declaration
public void setRotationAngle(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The number of degrees. |
Remarks
A positive value indicates clockwise rotation, a negative value indicates counterclockwise rotation.
setShowText(boolean value) Method
Indicates whether the code text is shown.
Declaration
public void setShowText(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
setSides(BorderSide value) Method
Sets barcode sides that display the border.
Declaration
public void setSides(BorderSide value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | BorderSide | Barcode sides with the border. |
setSizeMode(SizeMode value) Method
Sets how the control applies the specified width and height to the barcode.
Declaration
public void setSizeMode(SizeMode value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | SizeMode | A SizeMode enumeration value. |
Remarks
The following code snippet creates a QR Code barcode and customizes its encoding parameters with the Fluent API:
package barcodes;
import com.devexpress.drawing.*;
import com.devexpress.docs.barcode.*;
import com.devexpress.system.drawing.*;
import java.io.*;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
// Customize QR Code parameters.
QRCodeOptions options = QRCodeOptionsBuilder.create()
.withErrorCorrectionLevel(QRCodeErrorCorrectionLevel.H)
.withCompactionMode(QRCodeCompactionMode.AUTO)
.withVersion(QRCodeVersion.VERSION_10)
.withSizeMode(SizeMode.BARCODE_IMAGE)
.withWidth(300)
.withHeight(300)
.build();
Path outputDir = Path.of("output");
Files.createDirectories(outputDir);
try (FileOutputStream fileStream = new FileOutputStream(
outputDir.resolve("qrcode.png").toFile());
BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
barcodeGenerator.export(
"https://www.devexpress.com",
fileStream,
DXImageFormat.getPng());
}
}
}
Note
When using BARCODE_IMAGE, the barcode is rendered as an image. In this mode, the barcode’s width and height are mandatory scaling parameters. They define the size of the resulting barcode image in pixels.
setTextFont(DXFont value) Method
Sets the font used to draw barcode text.
Declaration
public void setTextFont(DXFont value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | DXFont | The font used to draw barcode text. |
setTextRenderingHint(DXTextRenderingHint value) Method
Sets the text rendering quality.
Declaration
public void setTextRenderingHint(DXTextRenderingHint value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | DXTextRenderingHint | The text rendering quality. |
setUnit(DXGraphicsUnit value) Method
Sets the unit of measurement for bar code settings.
Declaration
public void setUnit(DXGraphicsUnit value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | DXGraphicsUnit | An enumeration value that indicates the measurement units. |
setWidth(float value) Method
Sets the barcode width, in pixels
Declaration
public void setWidth(float value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | float | The barcode width. |
setWordWrap(boolean value) Method
Sets whether barcode text wraps if it overflows the barcode width.
Declaration
public void setWordWrap(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|