Example usage for com.itextpdf.text.pdf Barcode39 setBarHeight

List of usage examples for com.itextpdf.text.pdf Barcode39 setBarHeight

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf Barcode39 setBarHeight.

Prototype

public void setBarHeight(float barHeight) 

Source Link

Document

Sets the height of the bars.

Usage

From source file:com.betel.flowers.pdf.util.BarcodeGenerator.java

public static boolean createBarCode(String direccionXML, String direccionDestinoHtml) {
    Boolean exito = false;//from w  w w . jav  a 2  s. com
    try {
        String directorioDestino = direccionDestinoHtml;
        File archivo = new File(direccionXML);
        String claveAcceso = getClaveAcceso(archivo);
        StringBuilder sbca = new StringBuilder(claveAcceso);
        Barcode39 code39 = new Barcode39();
        code39.setCode(sbca.toString());
        code39.setX(0.75f);
        code39.setBarHeight(50f);
        java.awt.Image im = code39.createAwtImage(Color.WHITE, Color.BLACK);
        int w = im.getWidth(null);
        int h = im.getHeight(null);
        int type = BufferedImage.TYPE_INT_RGB; // other options
        BufferedImage dest = new BufferedImage(w, h, type);
        Graphics2D g2 = dest.createGraphics();
        g2.drawImage(im, 0, 0, null);
        g2.dispose();
        StringBuilder dirDestino = new StringBuilder(directorioDestino);
        dirDestino.append("/");
        dirDestino.append(claveAcceso);
        dirDestino.append(".gif");
        ImageIO.write(dest, "gif", new FileOutputStream(dirDestino.toString()));

    } catch (Exception ex) {
        System.out.println("no se pudo generar el codigo de barras " + ex.toString());
    }

    return exito;
}