Example usage for com.lowagie.text.pdf RadioCheckField setCheckType

List of usage examples for com.lowagie.text.pdf RadioCheckField setCheckType

Introduction

In this page you can find the example usage for com.lowagie.text.pdf RadioCheckField setCheckType.

Prototype

public void setCheckType(int checkType) 

Source Link

Document

Sets the checked symbol.

Usage

From source file:at.reppeitsolutions.formbuilder.components.pdf.itext.ITextRadio.java

License:Open Source License

@Override
public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
    PdfWriter writer = canvases[0].getPdfWriter();
    PdfFormField radiogroup = PdfFormField.createRadioButton(writer, true);
    radiogroup.setFieldName(UUID.randomUUID().toString());
    if (locked) {
        radiogroup.setFieldFlags(BaseField.READ_ONLY);
    }/*w w w  .j a  v  a2s  .  c  om*/
    RadioCheckField radio;
    for (int i = 0; i < values.length; i++) {
        try {
            Rectangle rect = getBoxRectangle(rectangle, i);
            radio = new RadioCheckField(writer, rect, null, UUID.randomUUID().toString());
            radio.setBorderColor(GrayColor.GRAYBLACK);
            radio.setBackgroundColor(GrayColor.GRAYWHITE);
            radio.setCheckType(RadioCheckField.TYPE_CIRCLE);
            if (value != null && values[i].equals(value)) {
                radio.setChecked(true);
            }
            PdfFormField field = radio.getRadioField();
            radiogroup.addKid(field);
            addBoxDescription(rectangle, i, values, canvases);
        } catch (IOException ex) {
            Logger.getLogger(ITextRadio.class.getName()).log(Level.SEVERE, null, ex);
        } catch (DocumentException ex) {
            Logger.getLogger(ITextRadio.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    writer.addAnnotation(radiogroup);
}

From source file:buckley.compile.CheckboxFieldFactory.java

License:Apache License

public PdfFormField buildFormField(RadioCheckField field) throws IOException, DocumentException {
    field.setCheckType(RadioCheckField.TYPE_CHECK);
    field.setChecked(false);/*w w  w  .  j a v  a 2s .  co  m*/
    return field.getCheckField();
}

From source file:com.geek.tutorial.itext.acroform.RadioCheckBoxForm.java

License:Open Source License

private static void addRadioButton(PdfWriter writer, Rectangle rect, PdfFormField radio, String name,
        boolean on) throws IOException, DocumentException {
    RadioCheckField check = new RadioCheckField(writer, rect, null, name);
    check.setCheckType(RadioCheckField.TYPE_CHECK);
    check.setBorderColor(Color.BLACK);
    check.setChecked(on);//from   w  w w . j a va2  s.c o m
    radio.addKid(check.getRadioField());
}

From source file:com.geek.tutorial.itext.acroform.RadioCheckBoxForm.java

License:Open Source License

private static void addCheckbox(PdfWriter writer, Rectangle rect, String name)
        throws IOException, DocumentException {
    RadioCheckField check = new RadioCheckField(writer, rect, name, "On");
    check.setCheckType(RadioCheckField.TYPE_CROSS);
    check.setBorderColor(Color.BLACK);
    writer.addAnnotation(check.getCheckField());
}

From source file:org.xhtmlrenderer.pdf.CheckboxFormField.java

License:Open Source License

public void paint(RenderingContext c, ITextOutputDevice outputDevice, BlockBox box) {
    PdfContentByte cb = outputDevice.getCurrentPage();

    PdfWriter writer = outputDevice.getWriter();
    Element elm = box.getElement();

    Rectangle targetArea = outputDevice.createLocalTargetArea(c, box);
    String onValue = getValue(elm);

    RadioCheckField field = new RadioCheckField(writer, targetArea, getFieldName(outputDevice, elm), onValue);

    field.setChecked(isChecked(elm));//from  w  ww  . ja  v a2 s.c om
    field.setCheckType(RadioCheckField.TYPE_CHECK);
    field.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
    //TODO Consider if we can get some more correct color
    field.setBorderColor(Color.black);

    field.setBorderWidth(BaseField.BORDER_WIDTH_THIN);

    try {
        PdfFormField formField = field.getCheckField();
        if (isReadOnly(elm)) {
            formField.setFieldFlags(PdfFormField.FF_READ_ONLY);
        }
        writer.addAnnotation(formField);
    } catch (IOException ioe) {
        System.out.println(ioe);
    } catch (DocumentException de) {
        System.out.println(de);
    }

}

From source file:questions.forms.RadioButtonsOnDifferentPages.java

private static void addRadioButton(PdfWriter writer, Rectangle rect, PdfFormField radio, String name,
        boolean on, int page) throws IOException, DocumentException {
    RadioCheckField check = new RadioCheckField(writer, rect, null, name);
    check.setCheckType(RadioCheckField.TYPE_CIRCLE);
    check.setChecked(on);//from w ww . ja  v  a  2s . co m
    PdfFormField field = check.getRadioField();
    field.setPlaceInPage(page);
    radio.addKid(field);
}