private String processScannedFiles(final String path,final String fileName) throws Exception {
  if (!isError) {
    if (scanMode == ScanModeConstants.SCAN_MODE_FILE) {
      if ((tempFiles != null) && !tempFiles.isEmpty()) {
        File file=(File)tempFiles.get(0);
        File newFile=new File(path,this.prefix);
        if (newFile.exists()) {
          newFile.delete();
        }
        file.renameTo(newFile);
        clearTempFiles();
        return fileName;
      }
 else {
        return null;
      }
    }
 else     if ((scanMode == ScanModeConstants.SCAN_MODE_NATIVE) || (scanMode == ScanModeConstants.SCAN_MODE_MEMORY)) {
      if ((tempFiles != null) && !tempFiles.isEmpty()) {
        File newFile=new File(path,this.prefix);
        if (newFile.exists()) {
          newFile.delete();
        }
        FileOutputStream fos=null;
        Document document=null;
        try {
          fos=new FileOutputStream(newFile);
          document=new Document();
          PdfWriter.getInstance(document,fos);
          document.open();
          File fileProperties=(File)tempFiles.get(0);
          Image imageProperties=Image.getInstance(fileProperties.getPath());
          document.setPageSize(imageProperties);
          document.setMargins(0,0,0,0);
          File file=null;
          Image image=null;
          Iterator it=tempFiles.iterator();
          while (it.hasNext()) {
            file=(File)it.next();
            document.newPage();
            image=Image.getInstance(file.getPath());
            document.add(image);
          }
        }
 catch (        Exception e) {
          throw e;
        }
 finally {
          if (document != null) {
            document.close();
          }
          if (fos != null) {
            fos.close();
          }
        }
        clearTempFiles();
        return newFile.getPath();
      }
 else {
        return null;
      }
    }
  }
 else {
    clearTempFiles();
  }
  return null;
}

private String processScannedFiles ( final String path , final String fileName ) throws Exception { if ( ! isError ) { if ( scanMode == ScanModeConstants . SCAN_MODE_FILE ) { if ( ( tempFiles != null ) && ! tempFiles . isEmpty ( ) ) { File file = ( File ) tempFiles . get ( 0 ) ; File newFile = new File ( path , this . prefix ) ; if ( newFile . exists ( ) ) { newFile . delete ( ) ; } file . renameTo ( newFile ) ; clearTempFiles ( ) ; return fileName ; } else { return null ; } } else if ( ( scanMode == ScanModeConstants . SCAN_MODE_NATIVE ) || ( scanMode == ScanModeConstants . SCAN_MODE_MEMORY ) ) { if ( ( tempFiles != null ) && ! tempFiles . isEmpty ( ) ) { File newFile = new File ( path , this . prefix ) ; if ( newFile . exists ( ) ) { newFile . delete ( ) ; } FileOutputStream fos = null ; Document document = null ; try { fos = new FileOutputStream ( newFile ) ; document = new Document ( ) ; PdfWriter . getInstance ( document , fos ) ; document . open ( ) ; File fileProperties = ( File ) tempFiles . get ( 0 ) ; Image imageProperties = Image . getInstance ( fileProperties . getPath ( ) ) ; document . setPageSize ( imageProperties ) ; document . setMargins ( 0 , 0 , 0 , 0 ) ; File file = null ; Image image = null ; Iterator it = tempFiles . iterator ( ) ; while ( it . hasNext ( ) ) { file = ( File ) it . next ( ) ; document . newPage ( ) ; image = Image . getInstance ( file . getPath ( ) ) ; document . add ( image ) ; } } catch ( Exception e ) { throw e ; } finally { if ( document != null ) { document . close ( ) ; } if ( fos != null ) { fos . close ( ) ; } } clearTempFiles ( ) ; return newFile . getPath ( ) ; } else { return null ; } } } else { clearTempFiles ( ) ; } return null ; }
permite procesar los ficheros escaneados y obtener el pdf final
