Example usage for com.lowagie.text.pdf PdfName FF

List of usage examples for com.lowagie.text.pdf PdfName FF

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfName FF.

Prototype

PdfName FF

To view the source code for com.lowagie.text.pdf PdfName FF.

Click Source Link

Document

A name

Usage

From source file:org.opensignature.opensignpdf.PDFSigner.java

License:Open Source License

/**
 * // w  w  w .ja va2s .co  m
 * @param pdfFile
 * @return
 * @throws IOException
 * @throws DocumentException
 * @throws FileNotFoundException
 */
private PdfReader createPDFReader(File pdfFile) throws IOException, DocumentException, FileNotFoundException {

    logger.info("[createPDFReader.in]:: " + Arrays.asList(new Object[] { pdfFile }));

    PdfReader reader;

    if ("true".equals(openOfficeSelected)) {
        String fileName = pdfFile.getPath();
        String tempFileName = fileName + ".temp";
        PdfReader documentPDF = new PdfReader(fileName);

        PdfStamperOSP stamperTemp = new PdfStamperOSP(documentPDF, new FileOutputStream(tempFileName));
        AcroFields af = stamperTemp.getAcroFields();
        af.setGenerateAppearances(true);
        PdfDictionary acro = (PdfDictionary) PdfReader
                .getPdfObject(documentPDF.getCatalog().get(PdfName.ACROFORM));
        acro.remove(PdfName.DR);
        HashMap fields = af.getFields();
        String key;
        for (Iterator it = fields.keySet().iterator(); it.hasNext();) {
            key = (String) it.next();
            int a = af.getFieldType(key);
            if (a == 4) {
                ArrayList widgets = af.getFieldItem(key).widgets;
                PdfDictionary widget = (PdfDictionary) widgets.get(0);
                widget.put(PdfName.FT, new PdfName("Sig"));
                widget.remove(PdfName.V);
                widget.remove(PdfName.DV);
                widget.remove(PdfName.TU);
                widget.remove(PdfName.FF);
                widget.remove(PdfName.DA);
                widget.remove(PdfName.DR);
                widget.remove(PdfName.AP);
            }
        }

        stamperTemp.close();
        documentPDF.close();
        reader = new PdfReader(pdfFile.getPath() + ".temp");

    } else {
        reader = new PdfReader(pdfFile.getPath());

    }

    logger.info("[createPDFReader.retorna]:: ");
    return reader;

}

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

License:Open Source License

/**
 * init//from   w  w  w.ja va 2 s  . co m
 */
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);
    }
}

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

License:Open Source License

/**
 * Tranforme les champs en nom modifiable
 * //from  w w w  .j a v a 2  s  . c o  m
 * @param form le field
 * @param name le nom
 */
private static void lockField(final AcroFields form, final String name) {
    final AcroFields.Item item = form.getFieldItem(name);
    if (item != null) {
        for (int k = 0; k < item.merged.size(); ++k) {
            PdfNumber num = (PdfNumber) PdfReader
                    .getPdfObject(((PdfDictionary) item.values.get(k)).get(PdfName.FF));
            int val = 0;

            if (num != null) {
                val = num.intValue();
            }

            num = new PdfNumber(val | PdfFormField.FF_READ_ONLY);

            ((PdfDictionary) item.merged.get(k)).put(PdfName.FF, num);
            ((PdfDictionary) item.values.get(k)).put(PdfName.FF, num);
        }
    }
}