* @throws PDFSecurityException if a security provider can not be found
     *                              or there is an error decrypting the file.
     */
    private void loadDocumentViaLinearTraversal(InputStream in)
            throws PDFException, PDFSecurityException {
        skipPastAnyPrefixJunk(in);

        library.setLinearTraversal();
        Parser parser = new Parser(in);

        // document Trailer, holds encryption info
        PTrailer documentTrailer = null;

        // Loop through all objects that where parsed from the data stream
        Object pdfObject;
        while (true) {
            // parse all of the objects in the stream,  objects are added
            // to the library object.
            pdfObject = parser.getObject(library);

            // eof or io error result in break
            if (pdfObject == null) {
                break;
            }

            // display object information in debug mode
            if (logger.isLoggable(Level.FINER)) {
                logger.finer(pdfObject.getClass().getName() + " " + pdfObject);
            }

            // Add any PObjects to the vector, so they can be decrypted
            if (pdfObject instanceof PObject) {
                PObject tmp = (PObject) pdfObject;
                Object obj = tmp.getObject();
                if (obj != null)
                    pdfObject = obj;
            }

            // find the catalog which has information on outlines
            // which is need by the gui
            if (pdfObject instanceof Catalog) {
                catalog = (Catalog) pdfObject;
            }

            // Find the trailer object so that we can get the encryption information
            // trailer information is not a PObject and thus there should
            if (pdfObject instanceof PTrailer) {
                if (documentTrailer == null) {
                    documentTrailer = (PTrailer) pdfObject;
                } else {
                    // add more trailer data to the original
                    PTrailer nextTrailer = (PTrailer) pdfObject;
                    documentTrailer.addNextTrailer(nextTrailer);
                    documentTrailer = nextTrailer;
                }
            }
        }

        // The LazyObjectLoader is used for both reading from a SeekableInput,
        //  and also accessing ObjectStreams.
        // So, even with linear traversal, we still need it for PDF 1.5 documents
        if (documentTrailer != null) {
            LazyObjectLoader lol = new LazyObjectLoader(
                    library, null, documentTrailer.getPrimaryCrossReference());
            library.setLazyObjectLoader(lol);
        }

        // apply the new object offset values so that the object can be retrieved
        // using the actual index in the file
        // todo, implement indexer.

        pTrailer = documentTrailer;
        library.setCatalog(catalog);

        // Add Document information object to catalog
        if (documentTrailer != null) {
            boolean madeSecurityManager = makeSecurityManager(documentTrailer);
            if (madeSecurityManager)
                attemptAuthorizeSecurityManager();
        }
    }