* @throws IOException If there is an error setting the data in the field.
*/
public void importFDF( PDDocument pdfDocument, COSDocument fdfDocument ) throws IOException
{
PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
acroForm.setCacheFields( true );
COSDictionary trailer = fdfDocument.getTrailer();
COSDictionary root = (COSDictionary)trailer.getDictionaryObject( COSName.ROOT );
COSDictionary fdf = (COSDictionary)root.getDictionaryObject( COSName.getPDFName( "FDF" ) );
if( fdf != null )
{
COSArray fields = (COSArray)fdf.getDictionaryObject( COSName.getPDFName( "Fields" ) );
for( int i=0; i<fields.size(); i++ )
{
COSDictionary fdfField = (COSDictionary)fields.getObject( i );
COSString fieldName = (COSString)fdfField.getDictionaryObject( COSName.getPDFName( "T" ) );
System.out.println( "Processing " + fieldName );
PDField docField = acroForm.getField( fieldName.getString() );
if( docField != null )
{
docField.importFDF( fdfField );
}
}