private static PdfDocument GetDocEnsureIndirect(PdfStructElem structElem) { PdfIndirectReference indRef = structElem.GetPdfObject().GetIndirectReference(); if (indRef == null) { throw new PdfException(PdfException.StructureElementDictionaryShallBeAnIndirectObjectInOrderToHaveChildren ); } return(indRef.GetDocument()); }
protected internal virtual PdfDocument GetDocument() { PdfDictionary structDict = GetPdfObject(); PdfIndirectReference indRef = structDict.GetIndirectReference(); if (indRef == null && structDict.GetAsDictionary(PdfName.P) != null) { // If parent is direct - it's definitely an invalid structure tree. // MustBeIndirect state won't be met during reading, and all newly created struct elements shall have ind ref. indRef = structDict.GetAsDictionary(PdfName.P).GetIndirectReference(); } return(indRef != null?indRef.GetDocument() : null); }