Example usage for com.lowagie.text.pdf PRAcroForm.FieldInformation get

List of usage examples for com.lowagie.text.pdf PRAcroForm.FieldInformation get

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PRAcroForm.FieldInformation get.

Prototype

public PdfObject get(PdfName key) 

Source Link

Document

Returns the PdfObject associated to the specified key.

Usage

From source file:org.squale.welcom.outils.pdf.advanced.WPdfFieldReader.java

License:Open Source License

/**
 * init/*from ww w  .  j  a  va  2s  . c om*/
 */
public void init() {
    for (int i = 0; i < pdfReader.getAcroForm().size(); i++) {

        final PRAcroForm.FieldInformation p = (PRAcroForm.FieldInformation) pdfReader.getAcroForm().getFields()
                .get(i);

        final WPdfField pf = new WPdfField();
        pf.setName(p.getName());

        // Si ce n'est pas un champs text alors on l'ignore
        if (!p.getInfo().contains(PdfName.FT)
                || !(((PdfName) p.getInfo().get(PdfName.FT)).toString().equals(PdfName.TX.toString()))) {
            pf.setType(WPdfFieldType.INCONNU);
        } else {
            if (p.getInfo().contains(PdfName.DV)) {
                pf.setDefaultValue(((PdfString) (p.getInfo().get(PdfName.DV))).toUnicodeString());
            }
            if (p.getInfo().contains(PdfName.V)) {
                pf.setValue(((PdfString) (p.getInfo().get(PdfName.V))).toUnicodeString());
            }
            if (p.getInfo().contains(PdfName.FF)) {
                final PdfNumber pn = (PdfNumber) p.getInfo().get(PdfName.FF);
                if ((pn.intValue() & PdfFormField.FF_MULTILINE) == PdfFormField.FF_MULTILINE) {
                    pf.setType(WPdfFieldType.MUTILINETEXT);
                } else {
                    pf.setType(WPdfFieldType.TEXT);
                }
            } else {
                pf.setType(WPdfFieldType.TEXT);
            }
        }
        fields.add(pf);
    }
}