'Generate _pageId2Num'

def _getPageNumberByIndirect(self, indirectRef):

    if (self._pageId2Num is None):
        id2num = {}
        for (i, x) in enumerate(self.pages):
            id2num[x.indirectRef.idnum] = i
        self._pageId2Num = id2num
    if isinstance(indirectRef, int):
        idnum = indirectRef
    else:
        idnum = indirectRef.idnum
    ret = self._pageId2Num.get(idnum, (-1))
    return ret
