private static void DeleteOldReferences(PdfArray all, PdfArray toDelete)
{
if (all == null || toDelete == null)
return;
foreach (PdfObject pi in toDelete) {
if (!pi.IsIndirect())
continue;
PRIndirectReference pir = (PRIndirectReference)pi;
for (int k = 0; k < all.Size; ++k) {
PdfObject po = all[k];
if (!po.IsIndirect())
continue;
PRIndirectReference pod = (PRIndirectReference)po;
if (pir.Number == pod.Number) {
all.Remove(k);
--k;
}
}
}
}