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

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            final File file = fileChooser.getSelectedFile();
            // make sure file being opened is valid
            String extension = FileExtensionUtils.getExtension(file);
            if (extension != null) {
                if (extension.equals(FileExtensionUtils.svg)) {
                    final Document doc = document;
                    final int pageIndex = documentViewController.getCurrentPageIndex();

                    if (statusLabel != null) {
                        Object[] messageArguments = new Object[]{
                                String.valueOf(pageIndex + 1),
                                file.getName()
                        };
                        MessageFormat formatter = new MessageFormat(
                                messageBundle.getString("viewer.dialog.exportSVG.status.exporting.msg"));
                        statusLabel.setText(formatter.format(messageArguments));
                    }

                    SwingWorker worker = new SwingWorker() {
                        public Object construct() {
                            // save the file
                            String error;
                            try {
                                // It is important to create a UTF-8 encoded file.
                                OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
                                SVG.createSVG(
                                        doc,
                                        pageIndex,
                                        out);
                                out.close();
                                error = null;
                            } catch (Throwable e) {
                                error = e.getMessage();
                                logger.log(Level.FINE, "Error exporting to SVG");
                            }
                            final String tmpMsg;
                            // finsished message
                            if (error != null) {
                                Object[] messageArguments = new Object[]{
                                        String.valueOf(pageIndex + 1),
                                        file.getName()
                                };
                                MessageFormat formatter =
                                        new MessageFormat(
                                                messageBundle.getString("viewer.dialog.exportSVG.status.exporting.msg"));
                                tmpMsg = formatter.format(messageArguments);
                            }
                            // problem message
                            else {
                                Object[] messageArguments = new Object[]{
                                        String.valueOf(pageIndex + 1),
                                        file.getName(),
                                        error
                                };
                                MessageFormat formatter = new MessageFormat(
                                        messageBundle.getString("viewer.dialog.exportSVG.status.error.msg"));
                                tmpMsg = formatter.format(messageArguments);
                            }
                            final String msg = tmpMsg;

                            Runnable doSwingWork = new Runnable() {
                                public void run() {
                                    if (statusLabel != null)
                                        statusLabel.setText(msg);
                                }
                            };
                            SwingUtilities.invokeLater(doSwingWork);
                            return null;
                        }
                    };
                    worker.setThreadPriority(Thread.MIN_PRIORITY);
                    worker.start();
                } else {
                    org.icepdf.ri.util.Resources.showMessageDialog(
                            viewer,
                            JOptionPane.INFORMATION_MESSAGE,
                            messageBundle,
                            "viewer.dialog.exportSVG.exportError.title",
                            "viewer.dialog.exportSVG.exportError.msg",
                            file.getName());
                }
                // save the default directory
                ViewModel.setDefaultFile(file);
            } else {
                org.icepdf.ri.util.Resources.showMessageDialog(
                        viewer,
                        JOptionPane.INFORMATION_MESSAGE,
                        messageBundle,
                        "viewer.dialog.exportSVG.noExtensionError.title",
                        "viewer.dialog.exportSVG.noExtensionError.msg");
                exportSVG();
            }
        }
    }