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;
}
}