Skip to main content

Interleaved 2 of 5 (ITF)

  • 2 minutes to read

Interleaved 2 of 5 (ITF) is a high-density, numeric-only barcode symbology derived from Standard 2 of 5. It encodes data in pairs of digits by interleaving bars and spaces, which enables compact representation and efficient scanning in industrial and distribution environments (such as warehousing and logistics).

Interleaved 2 of 5, DevExpress Barcode Generation API for Java

Refer to the following page for additional information: https://en.wikipedia.org/wiki/Interleaved_2_of_5

Configure Interleaved 2 of 5 Settings

Use the Interleaved2of5Options class to configure Interleaved 2 of 5 barcode settings.

Method Description
setCalculateChecksum(boolean value) Specifies whether to calculate and append a checksum digit for error detection.

The following code snippet creates an Interleaved 2 of 5 barcode and customizes its encoding parameters:

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 {

        Interleaved2of5Options options = new Interleaved2of5Options();
        options.setCalculateChecksum(true);
        options.setWideNarrowRatio(3);
        options.setPadding(new Padding(10));
        options.setShowText(true);
        options.setWidth(600);

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

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

Fluent API

Use the Interleaved2of5OptionsBuilder class to configure Interleaved 2 of 5 barcode settings with the Fluent API.

The following code snippet creates an Interleaved 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 {

        Interleaved2of5Options options = Interleaved2of5OptionsBuilder.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("interleaved2of5.png").toFile());
                BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                    barcodeGenerator.export(
                            "0123456709498765432101234567891",
                            fileStream,
                            DXImageFormat.getPng());
        }
    }
}
See Also