Ejemplo n.º 1
0
        /// <summary>Defines index of the current tag in the parent's kids list.</summary>
        /// <returns>
        /// returns index of the current tag in the parent's kids list, or -1
        /// if either current tag is a root tag, parent is flushed or it wasn't possible to define index.
        /// </returns>
        public virtual int GetIndexInParentKidsList()
        {
            if (GetCurrentStructElem().GetPdfObject() == tagStructureContext.GetRootTag().GetPdfObject())
            {
                return(-1);
            }
            PdfStructElem parent = (PdfStructElem)GetCurrentStructElem().GetParent();

            if (parent.IsFlushed())
            {
                return(-1);
            }
            PdfObject k = parent.GetK();

            if (k == GetCurrentStructElem().GetPdfObject())
            {
                return(0);
            }
            if (k.IsArray())
            {
                PdfArray kidsArr = (PdfArray)k;
                return(kidsArr.IndexOf(GetCurrentStructElem().GetPdfObject()));
            }
            return(-1);
        }