private PdfMcr PrepareMcrForMovingToNewParent(PdfMcr mcrKid, PdfStructElem newParent) { PdfObject mcrObject = mcrKid.GetPdfObject(); PdfDictionary mcrPage = mcrKid.GetPageObject(); PdfDictionary mcrDict = null; if (!mcrObject.IsNumber()) { mcrDict = (PdfDictionary)mcrObject; } if (mcrDict == null || !mcrDict.ContainsKey(PdfName.Pg)) { if (!EnsureElementPageEqualsKidPage(newParent, mcrPage)) { if (mcrDict == null) { mcrDict = new PdfDictionary(); mcrDict.Put(PdfName.Type, PdfName.MCR); mcrDict.Put(PdfName.MCID, mcrKid.GetPdfObject()); } // Explicitly using object indirect reference here in order to correctly process released objects. mcrDict.Put(PdfName.Pg, mcrPage.GetIndirectReference()); } } if (mcrDict != null) { if (PdfName.MCR.Equals(mcrDict.Get(PdfName.Type))) { mcrKid = new PdfMcrDictionary(mcrDict, newParent); } else { if (PdfName.OBJR.Equals(mcrDict.Get(PdfName.Type))) { mcrKid = new PdfObjRef(mcrDict, newParent); } } } else { mcrKid = new PdfMcrNumber((PdfNumber)mcrObject, newParent); } return(mcrKid); }
private PdfMcr PrepareMcrForMovingToNewParent(PdfMcr mcrKid, PdfStructElem newParent) { PdfObject mcrObject = mcrKid.GetPdfObject(); PdfDictionary mcrPage = mcrKid.GetPageObject(); PdfDictionary mcrDict = null; if (!mcrObject.IsNumber()) { mcrDict = (PdfDictionary)mcrObject; } if (mcrDict == null || !mcrDict.ContainsKey(PdfName.Pg)) { if (!EnsureElementPageEqualsKidPage(newParent, mcrPage)) { if (mcrDict == null) { mcrDict = new PdfDictionary(); mcrDict.Put(PdfName.Type, PdfName.MCR); mcrDict.Put(PdfName.MCID, mcrKid.GetPdfObject()); } mcrDict.Put(PdfName.Pg, mcrPage); } } if (mcrDict != null) { if (PdfName.MCR.Equals(mcrDict.Get(PdfName.Type))) { mcrKid = new PdfMcrDictionary(mcrDict, newParent); } else { if (PdfName.OBJR.Equals(mcrDict.Get(PdfName.Type))) { mcrKid = new PdfObjRef(mcrDict, newParent); } } } else { mcrKid = new PdfMcrNumber((PdfNumber)mcrObject, newParent); } return(mcrKid); }