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

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

Introduction

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

Prototype

public void setX(float x) 

Source Link

Document

Sets the minimum bar width.

Usage

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

public static boolean createBarCode(String direccionXML, String direccionDestinoHtml) {
    Boolean exito = false;/*w w w . j a v a 2 s . c o m*/
    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;
}