Example usage for com.lowagie.text.pdf BarcodeInter25 setCode

List of usage examples for com.lowagie.text.pdf BarcodeInter25 setCode

Introduction

In this page you can find the example usage for com.lowagie.text.pdf BarcodeInter25 setCode.

Prototype

public void setCode(String code) 

Source Link

Document

Sets the code to generate.

Usage

From source file:br.com.nordestefomento.jrimum.bopepo.view.guia.ViewerPDF.java

License:Apache License

private void setCodigoBarra() throws DocumentException {
    // Montando o cdigo de barras.
    BarcodeInter25 barCode = new BarcodeInter25();
    barCode.setCode(guia.getCodigoDeBarras().write());

    barCode.setExtended(true);//from w  ww.ja va  2 s. co  m
    barCode.setBarHeight(40);
    barCode.setFont(null);
    barCode.setN(3);

    PdfContentByte cb = null;

    // Verifcando se existe o field(campo) da imagem no template do boleto.
    float posCampoImgLogo[] = form.getFieldPositions("txtCodigoBarra");

    if (isNotNull(posCampoImgLogo)) {

        RectanglePDF field = new RectanglePDF(posCampoImgLogo);

        cb = stamper.getOverContent(field.getPage());
        Image imgBarCode = barCode.createImageWithBarcode(cb, null, null);

        PDFUtil.changeField2Image(stamper, field, imgBarCode);
    }
}

From source file:br.com.nordestefomento.jrimum.bopepo.view.ViewerPDF.java

License:Apache License

private void setCodigoBarra() throws DocumentException {

    // Montando o cdigo de barras.
    BarcodeInter25 barCode = new BarcodeInter25();
    barCode.setCode(boleto.getCodigoDeBarras().write());

    barCode.setExtended(true);//from  www .  ja  v a 2s  .c o  m
    barCode.setBarHeight(40);
    barCode.setFont(null);
    barCode.setN(3);

    // FICHA DE COMPENSAO
    PdfContentByte cb = null;

    // Verifcando se existe o field(campo) da imagem no template do boleto.
    float posCampoImgLogo[] = form.getFieldPositions("txtFcCodigoBarra");

    if (isNotNull(posCampoImgLogo)) {

        RectanglePDF field = new RectanglePDF(posCampoImgLogo);

        cb = stamper.getOverContent(field.getPage());
        Image imgBarCode = barCode.createImageWithBarcode(cb, null, null);

        PDFUtil.changeField2Image(stamper, field, imgBarCode);
    }
}

From source file:classroom.filmfestival_c.Movies23.java

public static void fillForm(String filename, AccreditationData data, OutputStream out)
        throws IOException, DocumentException {

    PdfReader reader = new PdfReader(filename);
    PdfStamper stamper = new PdfStamper(reader, out);

    AcroFields form = stamper.getAcroFields();
    form.setField("name", data.getName());
    form.setFieldProperty("type", "textcolor", data.getTypeColor(), null);
    form.setField("type", data.getTypeName());
    form.setField("number", data.getNumber(false));
    form.setFieldProperty("filmfestival", "bgcolor", data.getTypeColor(), null);
    form.regenerateField("filmfestival");

    if (data.getPhoto() != null) {
        PushbuttonField bt = form.getNewPushbuttonFromField("photo");
        bt.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
        bt.setProportionalIcon(true);/*w  w  w. j  a v  a 2 s.com*/
        bt.setImage(data.getPhoto());
        form.replacePushbuttonField("photo", bt.getField());
    }

    try {
        BarcodeInter25 code = new BarcodeInter25();
        code.setGenerateChecksum(true);
        code.setBarHeight(mm2pt(3));
        code.setCode(data.getNumber(true));
        code.setFont(null);
        PdfContentByte cb = new PdfContentByte(stamper.getWriter());
        PdfTemplate template = code.createTemplateWithBarcode(cb, null, null);
        PushbuttonField bt = form.getNewPushbuttonFromField("barcode");
        bt.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
        bt.setProportionalIcon(false);
        bt.setTemplate(template);
        form.replacePushbuttonField("barcode", bt.getField());
    } catch (Exception e) {
        // not a valid code, do nothing
    }

    stamper.setFormFlattening(data.isFlatten());
    stamper.close();
}

From source file:org.jrimum.bopepo.pdf.CodigoDeBarras.java

License:Apache License

public Image toImage() {

    // Montando o cdigo de barras.
    BarcodeInter25 barCode = new BarcodeInter25();
    barCode.setCode(this.write());

    barCode.setExtended(true);/*from w  ww  .ja  v  a 2 s.c om*/
    barCode.setBarHeight(35);
    barCode.setFont(null);
    barCode.setN(3);

    return barCode.createAwtImage(Color.BLACK, Color.WHITE);
}