public void exportText() {
        // Create and display a file saving dialog
        final JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle(messageBundle.getString("viewer.dialog.exportText.title"));
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.addChoosableFileFilter(FileExtensionUtils.getTextFileFilter());
        if (ViewModel.getDefaultFile() != null) {
            fileChooser.setCurrentDirectory(ViewModel.getDefaultFile());
        }
        // show the dialog
        int returnVal = fileChooser.showSaveDialog(viewer);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();
            // make sure file being opened is valid
            String extension = FileExtensionUtils.getExtension(file);
            if (extension != null) {
                // save the default directory
                ViewModel.setDefaultFile(file);

                TextExtractionTask textExtractionTask =
                        new TextExtractionTask(document, file, messageBundle);

                ProgressMonitor progressMonitor = new ProgressMonitor(
                        viewer, messageBundle.getString("viewer.dialog.exportText.progress.msg"),
                        "", 0, textExtractionTask.getLengthOfTask());
                progressMonitor.setProgress(0);
                progressMonitor.setMillisToDecideToPopup(0);

                TextExtractionGlue glue = new TextExtractionGlue(textExtractionTask, progressMonitor);
                Timer timer = new Timer(1000, glue); // 1000 milliseconds
                glue.setTimer(timer);

                textExtractionTask.go();
                timer.start();
            } else {
                org.icepdf.ri.util.Resources.showMessageDialog(
                        viewer,
                        JOptionPane.INFORMATION_MESSAGE,
                        messageBundle,
                        "viewer.dialog.exportText.noExtensionError.title",
                        "viewer.dialog.exportText.noExtensionError.msg");
                exportText();
            }
        }
    }