Skip to main content

Intelligent Mail Package (IMpb)

  • 2 minutes to read

Intelligent Mail Package Barcode (IMpb) is a one-dimensional barcode symbology used by the United States Postal Service (USPS) to identify, track, and route parcels and shipping containers. The symbology combines a postal routing code with package-specific information and supports end-to-end package tracking throughout the delivery process.

IMpb is based on the Code 128 symbology and encodes data according to USPS specifications (including service type information, mailer identifiers, and tracking numbers).

Intelligent Mail Package, DevExpress Barcode Generation API for Java

Configure Intelligent Mail Package Settings

Use the IntelligentMailPackageOptions class to configure Intelligent Mail Package barcode settings.

The following code snippet creates an Intelligent Mail Package 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 {

        IntelligentMailPackageOptions options = new IntelligentMailPackageOptions();
        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("intelligent-mail-package.png").toFile());
                BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                    barcodeGenerator.export(
                            "9205590175547700043210",
                            fileStream,
                            DXImageFormat.getPng());
        }
    }
}

Fluent API

Use the IntelligentMailPackageOptionsBuilder class to configure Intelligent Mail Package barcode settings with the Fluent API.

The following code snippet creates an Intelligent Mail Package 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 {

        IntelligentMailPackageOptions options = IntelligentMailPackageOptionsBuilder.create()
            .withPadding(new Padding(10))
            .withShowText(true)
            .withWidth(600)
            .build();

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

        try (FileOutputStream fileStream = new FileOutputStream(
                outputDir.resolve("intelligent-mail-package.png").toFile());
                BarcodeGenerator barcodeGenerator = new BarcodeGenerator(options)) {
                    barcodeGenerator.export(
                            "9205590175547700043210",
                            fileStream,
                            DXImageFormat.getPng());
        }
    }
}
See Also