Example usage for com.itextpdf.text.pdf XfaForm XfaForm

List of usage examples for com.itextpdf.text.pdf XfaForm XfaForm

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf XfaForm XfaForm.

Prototype

public XfaForm(PdfReader reader) throws IOException, ParserConfigurationException, SAXException 

Source Link

Document

A constructor from a PdfReader.

Usage

From source file:edu.clemson.lph.pdfgen.PDFUtils.java

License:Open Source License

/**
 * Use iText 5.x to determine whether a PDF contains an XFA form.
 * @param pdfDataIn/*  w  w w .  java2 s  .  co m*/
 * @return
 */
public static boolean isXFA(byte[] pdfDataIn) {
    boolean bRet = false;
    PdfReader reader;
    try {
        reader = new PdfReader(pdfDataIn);
        XfaForm form = new XfaForm(reader);
        bRet = form.isXfaPresent();
    } catch (IOException e) {
        logger.error(e);
        bRet = false;
    } catch (ParserConfigurationException e) {
        logger.error(e);
        bRet = false;
    } catch (SAXException e) {
        logger.error(e);
        bRet = false;
    }
    return bRet;
}

From source file:edu.clemson.lph.pdfgen.PDFUtils.java

License:Open Source License

public static Node getXFADataNode(byte[] pdfDataIn) {
    Node nData = null;/*  w  w w .j  a v a  2  s  .c o  m*/
    try {
        PdfReader reader = new PdfReader(pdfDataIn);
        XfaForm form = new XfaForm(reader);
        Node xmlNode = form.getDatasetsNode();
        if ("xfa:datasets".equals(xmlNode.getNodeName())) {
            nData = xmlNode.getFirstChild();
            if (!"xfa:data".equals(nData.getNodeName())) {
                System.err.println(nData.getNodeName());
                nData = null;
            }
        } else
            System.err.println(xmlNode.getNodeName());
    } catch (IOException e) {
        logger.error(e);
    } catch (ParserConfigurationException e) {
        logger.error(e);
    } catch (SAXException e) {
        logger.error(e);
    }

    return nData;
}