public void openDocument() throws PDFException, IOException, PDFSecurityException {

        // get reference to application scoped document cache.
        DocumentCache documentCache = (DocumentCache)
                FacesUtils.getManagedBean("documentCache");

        synchronized (documentLock) {

            if (document == null) {

                if (sharedSession) {
                    Document documentReference = documentCache.get(documentPath);
                    if (documentReference != null) {
                        document = documentReference;
                    } else {
                        document = new Document();
                        document.setFile(documentPath);
                        documentCache.put(documentPath, document);
                    }
                } else {
                    document = new Document();
                    document.setFile(documentPath);
                }

            }

            // document length.
            maxPages = document.getPageTree().getNumberOfPages();
            // page size
            calculatePageImageSize();
            generateDocumentID();

            // build swing outlines.
            Outlines outlines = document.getCatalog().getOutlines();
            if (outlines != null && outlines.getRootOutlineItem() != null) {
                // root tree node

                DefaultMutableTreeNode rootItem = new OutlineItemTreeNode(document.getPageTree(),
                        outlines.getRootOutlineItem());

                outline = new ArrayList<TreeNode>();
                outline.add(rootItem);

                // expand document outline.
                outlineCollapsed = false;
            } else {
                outlineCollapsed = true;
            }
        }
    }