}
private void exportXFDF( String[] args ) throws Exception
{
PDDocument pdf = null;
FDFDocument fdf = null;
try
{
if( args.length != 1 && args.length != 2 )
{
usage();
}
else
{
pdf = PDDocument.load( args[0] );
PDAcroForm form = pdf.getDocumentCatalog().getAcroForm();
if( form == null )
{
System.err.println( "Error: This PDF does not contain a form." );
}
else
{
String fdfName = null;
if( args.length == 2 )
{
fdfName = args[1];
}
else
{
if( args[0].length() > 4 )
{
fdfName = args[0].substring( 0, args[0].length() -4 ) + ".xfdf";
}
}
fdf = form.exportFDF();
fdf.saveXFDF( fdfName );
}
}
}
finally
{