Example usage for com.itextpdf.text.pdf BarcodePDF417 setErrorLevel

List of usage examples for com.itextpdf.text.pdf BarcodePDF417 setErrorLevel

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf BarcodePDF417 setErrorLevel.

Prototype

public void setErrorLevel(int errorLevel) 

Source Link

Document

Sets the error level correction for the barcode.

Usage

From source file:com.andom.websevice.MyWebService.java

@WebMethod(operationName = "imprimir")
public ObjFactura imprimir(@WebParam(name = "session") String session,
        @WebParam(name = "ObjProducto") ObjProducto objproducto) {

    try {//  w  w w.  ja va  2  s . com

        if ("123456".equals(session) && objproducto != null) {
            ObjFactura objFactura = new ObjFactura();
            BarcodePDF417 pdf417 = new BarcodePDF417();
            String text = "Testing Java Barcode";
            pdf417.setCodeRows(5);
            pdf417.setCodeColumns(18);
            pdf417.setErrorLevel(5);
            pdf417.setOptions(BarcodePDF417.PDF417_FORCE_BINARY);
            pdf417.setText(text.getBytes("ISO-8859-1"));

            java.awt.Image img2;
            img2 = pdf417.createAwtImage(Color.BLACK, Color.WHITE);
            File file1 = new File("D://barraPDF417.PNG");
            BufferedImage x1 = imageToBufferedImage(img2);
            writeImageToPNG(file1, x1);
            Image awt = (Image) x1;
            objFactura.setTimbre(awt);
            objFactura.setFactura(1);
            return objFactura;
        } else {
            return null;
        }
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(MyWebService.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
        Logger.getLogger(MyWebService.class.getName()).log(Level.SEVERE, null, ex);
    }
    //   ObjImage ojpadre2 = null;
    return null;
}