Example usage for com.lowagie.text.pdf Barcode128 CODE_C

List of usage examples for com.lowagie.text.pdf Barcode128 CODE_C

Introduction

In this page you can find the example usage for com.lowagie.text.pdf Barcode128 CODE_C.

Prototype

char CODE_C

To view the source code for com.lowagie.text.pdf Barcode128 CODE_C.

Click Source Link

Usage

From source file:be.fedict.eid.applet.service.impl.PdfGenerator.java

License:Open Source License

/**
 * Generate a Code128C barcode//from   www. j  a va 2s .  c  o m
 *
 * @param rrn unique Rijksregister number
 * @param cardNumber number of the card
 * @return Image containing barcode
 * @throws IOException
 * @throws BadElementException
 */
private Image createBarcodeImage(String rrn, String cardNumber) throws IOException, BadElementException {
    if (null == rrn || rrn.length() != 11 || null == cardNumber || cardNumber.length() < 9) {
        throw new IllegalArgumentException("Missing or invalid length for RRN or Card Number");
    }

    String lastDigits = cardNumber.substring(cardNumber.length() - 9);
    String code = rrn + lastDigits;

    Barcode128 barcode = new Barcode128();
    barcode.setCodeType(Barcode128.CODE_C);
    barcode.setCode(code);
    barcode.setFont(null);

    return Image.getInstance(barcode.createAwtImage(Color.BLACK, Color.WHITE), null, true);
}