iTextSharp.text.pdf.PdfCopy.CopyIndirect C# (CSharp) Метод

CopyIndirect() защищенный Метод

protected CopyIndirect ( PRIndirectReference inp, bool keepStructure, bool directRootKids ) : PdfIndirectReference
inp PRIndirectReference
keepStructure bool
directRootKids bool
Результат PdfIndirectReference
        protected virtual PdfIndirectReference CopyIndirect(PRIndirectReference inp, bool keepStructure, bool directRootKids)
        {
            PdfIndirectReference theRef;
            RefKey key = new RefKey(inp);
            IndirectReferences iRef;
            indirects.TryGetValue(key, out iRef);
            PdfObject obj = PdfReader.GetPdfObjectRelease(inp);
            if ((keepStructure) && (directRootKids))
                if (obj is PdfDictionary) {
                    PdfDictionary dict = (PdfDictionary) obj;
                    if (dict.Contains(PdfName.PG))
                        return null;
                }
            if (iRef != null) {
                theRef = iRef.Ref;
                if (iRef.Copied) {
                    return theRef;
                }
            }
            else {
                theRef = body.PdfIndirectReference;
                iRef = new IndirectReferences(theRef);
                indirects[key] =  iRef;
            }
            if (obj != null && obj.IsDictionary()) {
                PdfObject type = PdfReader.GetPdfObjectRelease(((PdfDictionary)obj).Get(PdfName.TYPE));
                if (type != null && PdfName.PAGE.Equals(type)) {
                    return theRef;
                }
            }
            iRef.SetCopied();

            obj = CopyObject(obj);
            parentObjects.Add(obj, inp);
            PdfObject res = CopyObject(obj, keepStructure, directRootKids);
            if (disableIndirects.ContainsKey(obj))
                iRef.Copied = false;
            if ((res != null) && !(res is PdfNull))
            {
                AddToBody(res, theRef);
                return theRef;
            }
            else {
                indirects.Remove(key);
                return null;
            }
        }

Same methods

PdfCopy::CopyIndirect ( PRIndirectReference inp ) : PdfIndirectReference

Usage Example

        private void AddKid(PdfObject obj)
        {
            if (!obj.IsIndirect())
            {
                return;
            }
            PRIndirectReference currRef = (PRIndirectReference)obj;

            PdfCopy.RefKey key = new PdfCopy.RefKey(currRef);
            if (!writer.indirects.ContainsKey(key))
            {
                writer.CopyIndirect(currRef, true, false);
            }
            PdfIndirectReference newKid = writer.indirects[key].Ref;

            if (writer.updateRootKids)
            {
                AddKid(structureTreeRoot, newKid);
            }
        }