public PdfMcrNumber(PdfPage page, PdfStructElem parent) : base(new PdfNumber(page.GetNextMcid()), parent) { }
private static void SeparateKids(PdfDictionary structElem, ICollection <PdfObject> firstPartElems, StructureTreeCopier.LastClonedAncestor lastCloned, PdfDocument document) { PdfObject k = structElem.Get(PdfName.K); // If /K entry is not a PdfArray - it would be a kid which we won't clone at the moment, because it won't contain // kids from both parts at the same time. It would either be cloned as an ancestor later, or not cloned at all. // If it's kid is struct elem - it would definitely be structElem from the first part, so we simply call separateKids for it. if (!k.IsArray()) { if (k.IsDictionary() && PdfStructElem.IsStructElem((PdfDictionary)k)) { SeparateKids((PdfDictionary)k, firstPartElems, lastCloned, document); } } else { PdfArray kids = (PdfArray)k; for (int i = 0; i < kids.Size(); ++i) { PdfObject kid = kids.Get(i); PdfDictionary dictKid = null; if (kid.IsDictionary()) { dictKid = (PdfDictionary)kid; } if (dictKid != null && PdfStructElem.IsStructElem(dictKid)) { if (firstPartElems.Contains(kid)) { SeparateKids((PdfDictionary)kid, firstPartElems, lastCloned, document); } else { if (dictKid.IsFlushed()) { throw new PdfException(PdfException.TagFromTheExistingTagStructureIsFlushedCannotAddCopiedPageTags); } // elems with no kids will not be marked as from the first part, // but nonetheless we don't want to move all of them to the second part; we just leave them as is if (dictKid.ContainsKey(PdfName.K)) { CloneParents(structElem, lastCloned, document); kids.Remove(i--); PdfStructElem.AddKidObject(lastCloned.clone, -1, kid); } } } else { if (!firstPartElems.Contains(kid)) { CloneParents(structElem, lastCloned, document); PdfMcr mcr; if (dictKid != null) { if (dictKid.Get(PdfName.Type).Equals(PdfName.MCR)) { mcr = new PdfMcrDictionary(dictKid, new PdfStructElem(lastCloned.clone)); } else { mcr = new PdfObjRef(dictKid, new PdfStructElem(lastCloned.clone)); } } else { mcr = new PdfMcrNumber((PdfNumber)kid, new PdfStructElem(lastCloned.clone)); } kids.Remove(i--); PdfStructElem.AddKidObject(lastCloned.clone, -1, kid); document.GetStructTreeRoot().GetParentTreeHandler().RegisterMcr(mcr); } } } } // re-register mcr if (lastCloned.ancestor == structElem) { lastCloned.ancestor = lastCloned.ancestor.GetAsDictionary(PdfName.P); lastCloned.clone = lastCloned.clone.GetAsDictionary(PdfName.P); } }
public PdfMcrNumber(PdfNumber pdfObject, PdfStructElem parent) : base(pdfObject, parent) { }
public virtual PdfStructElem AddKid(PdfStructElem structElem) { return(AddKid(-1, structElem)); }
public virtual PdfStructElem AddKid(int index, PdfStructElem structElem) { AddKidObject(index, structElem.GetPdfObject()); return(structElem); }
public PdfMcrDictionary(PdfDictionary pdfObject, PdfStructElem parent) : base(pdfObject, parent) { }
protected internal PdfMcr(PdfObject pdfObject, PdfStructElem parent) : base(pdfObject) { this.parent = parent; }