public void ConsolidateNamedDestinations() {
if (consolidateNamedDestinations)
return;
consolidateNamedDestinations = true;
Hashtable names = GetNamedDestination(true);
if (names.Count == 0)
return;
for (int k = 1; k <= pageRefs.Size; ++k) {
PdfDictionary page = pageRefs.GetPageN(k);
PdfObject annotsRef;
PdfArray annots = (PdfArray)GetPdfObject(annotsRef = page.Get(PdfName.ANNOTS));
int annotIdx = lastXrefPartial;
ReleaseLastXrefPartial();
if (annots == null) {
pageRefs.ReleasePage(k);
continue;
}
bool commitAnnots = false;
for (int an = 0; an < annots.Size; ++an) {
PdfObject objRef = annots[an];
if (ReplaceNamedDestination(objRef, names) && !objRef.IsIndirect())
commitAnnots = true;
}
if (commitAnnots)
SetXrefPartialObject(annotIdx, annots);
if (!commitAnnots || annotsRef.IsIndirect())
pageRefs.ReleasePage(k);
}
PdfDictionary outlines = (PdfDictionary)GetPdfObjectRelease(catalog.Get(PdfName.OUTLINES));
if (outlines == null)
return;
IterateBookmarks(outlines.Get(PdfName.FIRST), names);
}