コード例 #1
0
        /// <summary>Flushes the tags which are considered to belong to the given page.</summary>
        /// <remarks>
        /// Flushes the tags which are considered to belong to the given page.
        /// The logic that defines if the given tag (structure element) belongs to the page is the following:
        /// if all the marked content references (dictionary or number references), that are the
        /// descendants of the given structure element, belong to the current page - the tag is considered
        /// to belong to the page. If tag has descendants from several pages - it is flushed, if all other pages except the
        /// current one are flushed.
        /// <br /><br />
        /// If some of the page's tags have waiting state (see
        /// <see cref="WaitingTagsManager"/>
        /// these tags are considered
        /// as not yet finished ones, and they and their children won't be flushed.
        /// </remarks>
        /// <param name="page">a page which tags will be flushed</param>
        /// <returns>
        /// current
        /// <see cref="TagStructureContext"/>
        /// instance
        /// </returns>
        public virtual iText.Kernel.Pdf.Tagutils.TagStructureContext FlushPageTags(PdfPage page)
        {
            PdfStructTreeRoot    structTreeRoot = document.GetStructTreeRoot();
            ICollection <PdfMcr> pageMcrs       = structTreeRoot.GetPageMarkedContentReferences(page);

            if (pageMcrs != null)
            {
                foreach (PdfMcr mcr in pageMcrs)
                {
                    PdfStructElem parent = (PdfStructElem)mcr.GetParent();
                    FlushParentIfBelongsToPage(parent, page);
                }
            }
            return(this);
        }
コード例 #2
0
        /// <summary>Removes all tags that belong only to this page.</summary>
        /// <remarks>
        /// Removes all tags that belong only to this page. The logic which defines if tag belongs to the page is described
        /// at
        /// <see cref="FlushPageTags(iText.Kernel.Pdf.PdfPage)"/>.
        /// </remarks>
        /// <param name="page">page that defines which tags are to be removed</param>
        /// <returns>
        /// current
        /// <see cref="TagStructureContext"/>
        /// instance
        /// </returns>
        public virtual iText.Kernel.Pdf.Tagutils.TagStructureContext RemovePageTags(PdfPage page)
        {
            PdfStructTreeRoot    structTreeRoot = document.GetStructTreeRoot();
            ICollection <PdfMcr> pageMcrs       = structTreeRoot.GetPageMarkedContentReferences(page);

            if (pageMcrs != null)
            {
                // We create a copy here, because pageMcrs is backed by the internal collection which is changed when mcrs are removed.
                IList <PdfMcr> mcrsList = new List <PdfMcr>(pageMcrs);
                foreach (PdfMcr mcr in mcrsList)
                {
                    RemovePageTagFromParent(mcr, mcr.GetParent());
                }
            }
            return(this);
        }