示例#1
0
 /// <summary>
 /// Creates
 /// <c>TagTreePointer</c>
 /// instance. After creation
 /// <c>TagTreePointer</c>
 /// points at the root tag.
 /// <p>
 /// The
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfNamespace"/>
 /// for the new tags, which don't explicitly define namespace by the means of
 /// <see cref="DefaultAccessibilityProperties.SetNamespace(iText.Kernel.Pdf.Tagging.PdfNamespace)"/>
 /// , is set to the value returned by
 /// <see cref="TagStructureContext.GetDocumentDefaultNamespace()"/>
 /// on
 /// <see cref="TagTreePointer"/>
 /// creation.
 /// See also
 /// <see cref="SetNamespaceForNewTags(iText.Kernel.Pdf.Tagging.PdfNamespace)"/>
 /// .
 /// </p>
 /// </summary>
 /// <param name="document">the document, at which tag structure this instance will point.</param>
 public TagTreePointer(PdfDocument document)
 {
     // '-1' value of this field means that next new kid will be the last element in the kids array
     tagStructureContext = document.GetTagStructureContext();
     SetCurrentStructElem(tagStructureContext.GetRootTag());
     SetNamespaceForNewTags(tagStructureContext.GetDocumentDefaultNamespace());
 }
示例#2
0
        /// <summary>
        /// Moves current tag to the tag at which given
        /// <c>TagTreePointer</c>
        /// points.
        /// This method doesn't change either this instance or pointerToNewParent position.
        /// </summary>
        /// <param name="pointerToNewParent">
        /// the
        /// <c>TagTreePointer</c>
        /// which is positioned at the tag
        /// which will become current tag new parent.
        /// </param>
        /// <returns>
        /// this
        /// <see cref="TagTreePointer"/>
        /// instance.
        /// </returns>
        public virtual iText.Kernel.Pdf.Tagutils.TagTreePointer Relocate(iText.Kernel.Pdf.Tagutils.TagTreePointer
                                                                         pointerToNewParent)
        {
            if (GetCurrentStructElem().GetPdfObject() == tagStructureContext.GetRootTag().GetPdfObject())
            {
                throw new PdfException(PdfException.CannotRelocateRootTag);
            }
            if (GetCurrentStructElem().IsFlushed())
            {
                throw new PdfException(PdfException.CannotRelocateTagWhichIsAlreadyFlushed);
            }
            int i = GetIndexInParentKidsList();

            if (i < 0)
            {
                throw new PdfException(PdfException.CannotRelocateTagWhichParentIsAlreadyFlushed);
            }
            new iText.Kernel.Pdf.Tagutils.TagTreePointer(this).MoveToParent().RelocateKid(i, pointerToNewParent);
            return(this);
        }
示例#3
0
 /// <summary>
 /// Creates
 /// <c>TagTreePointer</c>
 /// instance.
 /// </summary>
 /// <remarks>
 /// Creates
 /// <c>TagTreePointer</c>
 /// instance. After creation
 /// <c>TagTreePointer</c>
 /// points at the root tag.
 /// <para />
 /// The
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfNamespace"/>
 /// for the new tags, which don't explicitly define namespace by the means of
 /// <see cref="DefaultAccessibilityProperties.SetNamespace(iText.Kernel.Pdf.Tagging.PdfNamespace)"/>
 /// , is set to the value returned by
 /// <see cref="TagStructureContext.GetDocumentDefaultNamespace()"/>
 /// on
 /// <see cref="TagTreePointer"/>
 /// creation.
 /// See also
 /// <see cref="SetNamespaceForNewTags(iText.Kernel.Pdf.Tagging.PdfNamespace)"/>.
 /// </remarks>
 /// <param name="document">the document, at which tag structure this instance will point.</param>
 public TagTreePointer(PdfDocument document)
 {
     tagStructureContext = document.GetTagStructureContext();
     SetCurrentStructElem(tagStructureContext.GetRootTag());
     SetNamespaceForNewTags(tagStructureContext.GetDocumentDefaultNamespace());
 }
示例#4
0
 /// <summary>
 /// Moves this
 /// <c>TagTreePointer</c>
 /// instance to the document root tag.
 /// </summary>
 /// <returns>
 /// this
 /// <see cref="TagStructureContext"/>
 /// instance.
 /// </returns>
 public virtual iText.Kernel.Pdf.Tagutils.TagTreePointer MoveToRoot()
 {
     SetCurrentStructElem(tagStructureContext.GetRootTag());
     return(this);
 }