private bool EnsureElementPageEqualsKidPage(PdfStructElem elem, PdfDictionary kidPage) { PdfObject pageObject = elem.GetPdfObject().Get(PdfName.Pg); if (pageObject == null) { pageObject = kidPage; // Explicitly using object indirect reference here in order to correctly process released objects. elem.Put(PdfName.Pg, kidPage.GetIndirectReference()); } return(kidPage.Equals(pageObject)); }