public void dispose() {
        if (catalog != null) {
            catalog.dispose(false);
            catalog = null;
        }
        if (library != null) {
            library.dispose();
            library = null;
        }
        pTrailer = null;
        if (documentSeekableInput != null) {
            try {
                documentSeekableInput.close();
            }
            catch (IOException e) {
                logger.log(Level.FINE, "Error closing document input stream.", e);
            }
            documentSeekableInput = null;
        }
        String fileToDelete = getDocumentCachedFilePath();
        if (fileToDelete != null) {
            File file = new File(fileToDelete);
            boolean success = file.delete();
            if (!success && logger.isLoggable(Level.WARNING)) {
                logger.warning("Error deleting URL cached to file " + fileToDelete);
            }
        }
    }