'Internal function used to locate the first XRef.'

def find_xref(self):

    prev = None
    for line in self.revreadlines():
        line = line.strip()
        if (2 <= self.debug):
            print >>sys.stderr, ('find_xref:    %r' % line)
        if (line == 'startxref'):
            break
        if line:
            prev = line
    else:
        raise PDFNoValidXRef('Unexpected    EOF')
    if (1 <= self.debug):
        print >>sys.stderr, ('xref    found:    pos=%r' % prev)
    return long(prev)
