'Removes any named destinations that are not a part of the specified
page set.'

def _trim_dests(self, pdf, dests, pages):

    new_dests = []
    prev_header_added = True
    for (k, o) in list(dests.items()):
        for j in range(*pages):
            if (pdf.getPage(j).getObject() == o['/Page'].getObject()):
                o[NameObject('/Page')] = o['/Page'].getObject()
                assert (str_(k) == str_(o['/Title']))
                new_dests.append(o)
                break
    return new_dests
