private void parseFile(PDFPassword password) throws IOException {
  buf.rewind();
  String versionLine=readLine();
  if (versionLine.startsWith(VERSION_COMMENT)) {
    processVersion(versionLine.substring(VERSION_COMMENT.length()));
  }
  buf.rewind();
  byte[] scan=new byte[32];
  int scanPos=buf.remaining() - scan.length;
  int loc=0;
  while (scanPos >= 0) {
    buf.position(scanPos);
    buf.get(scan);
    String scans=new String(scan);
    loc=scans.indexOf("startxref");
    if (loc > 0) {
      if (scanPos + loc + scan.length <= buf.limit()) {
        scanPos=scanPos + loc;
        loc=0;
      }
      break;
    }
    scanPos-=scan.length - 10;
  }
  if (scanPos < 0) {
    throw new IOException("This may not be a PDF File");
  }
  buf.position(scanPos);
  buf.get(scan);
  String scans=new String(scan);
  loc+=10;
  if (scans.charAt(loc) < 32) {
    loc++;
  }
  while (scans.charAt(loc) == 32) {
    loc++;
  }
  int numstart=loc;
  while (loc < scans.length() && scans.charAt(loc) >= '0' && scans.charAt(loc) <= '9') {
    loc++;
  }
  int xrefpos=Integer.parseInt(scans.substring(numstart,loc));
  buf.position(xrefpos);
  try {
    readTrailer(password);
  }
 catch (  UnsupportedEncryptionException e) {
    throw new PDFParseException(e.getMessage(),e);
  }
}

private void parseFile ( PDFPassword password ) throws IOException { buf . rewind ( ) ; String versionLine = readLine ( ) ; if ( versionLine . startsWith ( VERSION_COMMENT ) ) { processVersion ( versionLine . substring ( VERSION_COMMENT . length ( ) ) ) ; } buf . rewind ( ) ; byte [ ] scan = new byte [ 32 ] ; int scanPos = buf . remaining ( ) - scan . length ; int loc = 0 ; while ( scanPos >= 0 ) { buf . position ( scanPos ) ; buf . get ( scan ) ; String scans = new String ( scan ) ; loc = scans . indexOf ( "startxref" ) ; if ( loc > 0 ) { if ( scanPos + loc + scan . length <= buf . limit ( ) ) { scanPos = scanPos + loc ; loc = 0 ; } break ; } scanPos -= scan . length - 10 ; } if ( scanPos < 0 ) { throw new IOException ( "This may not be a PDF File" ) ; } buf . position ( scanPos ) ; buf . get ( scan ) ; String scans = new String ( scan ) ; loc += 10 ; if ( scans . charAt ( loc ) < 32 ) { loc ++ ; } while ( scans . charAt ( loc ) == 32 ) { loc ++ ; } int numstart = loc ; while ( loc < scans . length ( ) && scans . charAt ( loc ) >= '0' && scans . charAt ( loc ) <= '9' ) { loc ++ ; } int xrefpos = Integer . parseInt ( scans . substring ( numstart , loc ) ) ; buf . position ( xrefpos ) ; try { readTrailer ( password ) ; } catch ( UnsupportedEncryptionException e ) { throw new PDFParseException ( e . getMessage ( ) , e ) ; } }
build the pdffile reference table . nothing in the pdffile actually gets parsed , despite the name of this function . things only get read and parsed when they ' re needed .
