Example usage for com.lowagie.text.pdf PdfFormField FF_MULTISELECT

List of usage examples for com.lowagie.text.pdf PdfFormField FF_MULTISELECT

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfFormField FF_MULTISELECT.

Prototype

int FF_MULTISELECT

To view the source code for com.lowagie.text.pdf PdfFormField FF_MULTISELECT.

Click Source Link

Usage

From source file:questions.forms.MultipleChoice.java

public static void createPdf() throws IOException, DocumentException {
    // step 1//  ww  w  .j  a  v  a  2  s . c  om
    Document document = new Document();
    // step 2
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
    // step 3
    document.open();
    // step 4
    TextField field = new TextField(writer, new Rectangle(36, 750, 144, 806), "iText");
    field.setFontSize(9);
    String[] list_options = { "JAVA", "C", "CS", "VB", "PHP" };
    field.setChoiceExports(list_options);
    String[] list_values = { "Java", "C/C++", "C#", "VB", "PHP" };
    field.setChoices(list_values);
    PdfFormField f = field.getListField();
    f.setFieldFlags(PdfFormField.FF_MULTISELECT);
    f.put(PdfName.I, new PdfArray(new int[] { 0, 2 }));
    writer.addAnnotation(f);
    // step 5
    document.close();
}