private void loadDocumentViaXRefs(SeekableInput in)
            throws PDFException, PDFSecurityException, IOException {
        //if( true ) throw new RuntimeException("Fallback to linear traversal");
        long xrefPosition = getInitialCrossReferencePosition(in);
        PTrailer documentTrailer = null;
        while (xrefPosition > 0L) {
            in.seekAbsolute(xrefPosition);

            Parser parser = new Parser(in);
            Object obj = parser.getObject(library);
            if (obj instanceof PObject)
                obj = ((PObject) obj).getObject();
            PTrailer trailer = (PTrailer) obj;
            //PTrailer trailer = (PTrailer) parser.getObject( library );
            if (trailer == null)
                throw new RuntimeException("Could not find trailer");
            if (trailer.getPrimaryCrossReference() == null)
                throw new RuntimeException("Could not find cross reference");
            trailer.setPosition(xrefPosition);

            if (documentTrailer == null)
                documentTrailer = trailer;
            else
                documentTrailer.addPreviousTrailer(trailer);

            // If this trailer has everything we need to get started,
            //   then we can lazily load other trailers later
            if (true) //TODO So should we make this not be a loop then?
                break;
            xrefPosition = trailer.getPrev();
        }
        if (documentTrailer == null)
            throw new RuntimeException("Could not find document trailer");

        LazyObjectLoader lol = new LazyObjectLoader(
                library, in, documentTrailer.getPrimaryCrossReference());
        library.setLazyObjectLoader(lol);

        pTrailer = documentTrailer;
        catalog = documentTrailer.getRootCatalog();
        library.setCatalog(catalog);

        if (catalog == null)
            throw new NullPointerException("Loading via xref failed to find catalog");

        boolean madeSecurityManager = makeSecurityManager(documentTrailer);
        if (madeSecurityManager)
            attemptAuthorizeSecurityManager();
    }