public void closeDocument() {
        synchronized (documentLock) {
            try {
                if (document != null) {
                    document.dispose();
                }
                document = null;
                outline = null;
                maxPages = -1;
                isStateChanged = true;
            } catch (Throwable e) {
                logger.log(Level.FINE, "Could not close document.", e);
            }
        }
    }