Skip to main content

Industrial2of5OptionsBuilder Class

Builds an Industrial2of5Options object. Chain builder methods to configure barcode settings, then call the build() method to create the options object.

Declaration

public class Industrial2of5OptionsBuilder extends BarcodeOptionsBuilder<Industrial2of5Options,Industrial2of5OptionsBuilder>

Remarks

Refer to the following help topic for additional information: Industrial 2 of 5.

The following code snippet creates an Industrial 2 of 5 barcode and customizes its encoding parameters with the Fluent API:

import com.devexpress.drawing.*;
import com.devexpress.docs.barcode.*;
import com.devexpress.system.drawing.*;
import com.devexpress.docs.Padding;

import java.io.*;
import java.nio.file.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Industrial2of5Options options = Industrial2of5OptionsBuilder.create()
            .withCalculateChecksum(true)
            .withWideNarrowRatio(3)
            .withPadding(new Padding(10))
            .withShowText(true)
            .withWidth(600)
            .build();

        Path outputDir = Path.of("output");
        Files.createDirectories(outputDir);

        try (FileOutputStream fileStream = new FileOutputStream(
                outputDir.resolve("industrial2of5.png").toFile());
                BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                    barcodeGenerator.export(
                            "12345670",
                            fileStream,
                            DXImageFormat.getPng());
        }
    }
}

Inherited Members

com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
JavaObject
BarcodeOptionsBuilder<TOptions,TBuilder>
Industrial2of5OptionsBuilder

Industrial2of5OptionsBuilder()

Initializes a new instance of the Industrial2of5OptionsBuilder class.

Declaration

public Industrial2of5OptionsBuilder()

Methods

create() Method

Creates an Industrial2of5OptionsBuilder instance.

Declaration

public static Industrial2of5OptionsBuilder create()

Returns

Type Description
Industrial2of5OptionsBuilder

The created instance.

withCalculateChecksum(boolean calculate) Method

Specifies whether a check character should be calculated and added to the barcode data. Returns the builder instance for method chaining.

Declaration

public Industrial2of5OptionsBuilder withCalculateChecksum(boolean calculate)

Parameters

Name Type Description
calculate boolean

true, to add a check character; otherwise, false.

Returns

Type Description
Industrial2of5OptionsBuilder

The builder instance with the updated settings.

withWideNarrowRatio(float ratio) Method

Specifies the wide bar to narrow bar ratio and returns the builder instance for method chaining.

Declaration

public Industrial2of5OptionsBuilder withWideNarrowRatio(float ratio)

Parameters

Name Type Description
ratio float

The density of barcode bars.

Returns

Type Description
Industrial2of5OptionsBuilder

The current Industrial2of5OptionsBuilder instance for method chaining.