org.faceless.pdf2
Class FDF

java.lang.Object
  extended by org.faceless.pdf2.FDF

public final class FDF
extends Object

A class representing an FDF object. "FDF" stands for "Forms Data Format", and is Adobes format for submitting form data from a PDF to a server, and generating a response. XFDF, an XML representation of FDF, can be handled the same way.

This class supports both loading an existing FDF file which can be imported into a PDF via the PDF.importFDF() method, and creating a new FDF from a PDF which can then be rendered via the render(java.io.OutputStream) method.

Here's a simple example showing how to complete a PDF form with an FDF and save the completed PDF to an OutputStream.

   PDF pdf = new PDF(new PDFReader(new FileInputStream("blankform.pdf")));
   FDF fdf = new FDF(new InputStream("data.fdf"));
   pdf.importFDF(fdf);
   pdf.render(outputstream);
 

Since:
1.2.1
See Also:
PDF.importFDF(org.faceless.pdf2.FDF), Form

Constructor Summary
FDF(InputStream fdfstream)
          Create a new FDF from the specified InputStream.
FDF(PDF pdf)
          Create a new FDF from the specified PDF.
 
Method Summary
 String getDocumentID(boolean primary)
          Return the document ID that this FDF belongs to.
 Map getFields()
          Return a read-only map of all the field values in the FDF.
 String getFile()
          Return the file associated with this FDF (the "F" entry), or null if not set.
 void render(OutputStream out)
          Render this object as an FDF to the specified OutputStream.
 void setFields(Collection fields)
          Set the fields that are to be included in this FDF.
 void setIgnoreErrors(boolean ignore)
          Whether to ignore errors when importing this FDF.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FDF

public FDF(InputStream fdfstream)
    throws IOException
Create a new FDF from the specified InputStream. The InputStream must be formatted as an FDF file, or since 2.2.4 an XFDF file (although this requires a SAX implementation to run). Note the InputStream is not closed by this method, and should be closed by the user.

Parameters:
fdfstream - an InputStream containing the form data.
Throws:
IOException

FDF

public FDF(PDF pdf)
Create a new FDF from the specified PDF. This FDF may eventually be rendered using the render(java.io.OutputStream) method.

Since:
2.8.3
Method Detail

setFields

public void setFields(Collection fields)
Set the fields that are to be included in this FDF. Can only be called if the FDF was created using the FDF(PDF) constructor.

Parameters:
fields - the fields to include - eg. pdf.getForm().getElements().values() or PDFAction.getFormSubmitFields()
Since:
2.8.3

getFields

public Map getFields()
Return a read-only map of all the field values in the FDF. Note this is just the field values - if the FDF contains other details, like annotations and the like, these will not be included.

Since:
2.10

getFile

public String getFile()
Return the file associated with this FDF (the "F" entry), or null if not set.

Since:
2.2.2

getDocumentID

public String getDocumentID(boolean primary)
Return the document ID that this FDF belongs to. This method functions exactly the same as the PDF.getDocumentID(boolean) method, but returns the ID of the document associated with this FDF (or null if this is not specified)

Parameters:
primary - whether to return the primary or secondary ID
Returns:
a 32-character String representing the ID, or null if no ID is set
Since:
2.2.2

setIgnoreErrors

public void setIgnoreErrors(boolean ignore)
Whether to ignore errors when importing this FDF. The default value is false, which means trying to set a field to an illegal value will throw an Exception. By setting this value to true, a warning will be displayed instead and the import will continue

Since:
2.2.6

render

public void render(OutputStream out)
            throws IOException
Render this object as an FDF to the specified OutputStream.

Throws:
IOException
Since:
2.8.3


Copyright © 2001-2008 Big Faceless Organization