def build_index_from_xref_sequence(xref_seq: list, nxt: dict, nb: int) -> list:
    """Build a multi-dimensional array where each column represents a doc update."""
    nb = nb + 2
    m = nb * [None]
    abs_pos_array = nb * [0]
    index = []
    doc_ver = -1
    prev_pos = 0
    xref_seq = xref_seq[:]
    xref_seq.reverse()
    new_xref_seq = []
    for x in xref_seq:
        if x[0].get('xref_stm'):
            p = new_xref_seq[-1]
            p = deepcopy(p)
            p[0]['xref_stm'] = True
            p[0]['abs_pos'] = x[0]['abs_pos']
            new_xref_seq[-1] = p
        else:
            new_xref_seq.append(x)
    for x in new_xref_seq:
        trailer = x[0]
        if trailer['abs_pos'] > prev_pos: # or trailer.get('xref_stm'):
            m = m[:]
            index.append(m)
            doc_ver += 1
            m[0] = trailer
            prev_pos = trailer['abs_pos']
        else:
            m[0] = [m[0], trailer]
        trailer['o_ver'] = doc_ver
        trailer['doc_ver'] = doc_ver
        for obj in x[1:]:
            if m[obj['o_num']] is None:
                obj['o_ver'] = 0
                obj['doc_ver'] = doc_ver
            else:
                old_obj = index[-1][obj['o_num']]
                if 'abs_pos' in old_obj and 'abs_pos' in obj and old_obj['abs_pos'] == obj['abs_pos']:
                    #Special case for hybrid docs where an obj appears both in xref table and stream
                    obj = old_obj
                else:
                    obj['o_ver'] = old_obj['o_ver'] + 1
                    obj['doc_ver'] = doc_ver
            m[obj['o_num']] = obj
    for current in index:
        for x in current:
            if x is None:
                continue
            elif type(x) == dict:
                x = [x]
            for y in x:
                if y.get('abs_next'):
                    continue
                abs_pos = y.get('abs_pos')
                env_num = y.get('env_num')
                if type(abs_pos) == tuple:
                    e, offset = abs_pos
                    loc = current[e]['abs_pos']
                    y['abs_pos'] = loc + (offset + 1) / 10000
                    abs_pos = loc
                y['abs_next'] = nxt[abs_pos]
    return index
Build a multi-dimensional array where each column represents a doc update.
pdfsyntax/filestruct.py