示例#1
0
        /// <exception cref="System.IO.IOException"/>
        protected internal virtual void ParseTag(PdfMcr kid)
        {
            int           mcid       = kid.GetMcid();
            PdfDictionary pageDic    = kid.GetPageObject();
            String        tagContent = "";

            if (mcid != -1)
            {
                if (!parsedTags.ContainsKey(pageDic))
                {
                    TaggedPdfReaderTool.MarkedContentEventListener listener = new TaggedPdfReaderTool.MarkedContentEventListener
                                                                                  (this);
                    PdfCanvasProcessor processor = new PdfCanvasProcessor(listener);
                    PdfPage            page      = document.GetPage(pageDic);
                    processor.ProcessContent(page.GetContentBytes(), page.GetResources());
                    parsedTags[pageDic] = listener.GetMcidContent();
                }
                if (parsedTags.Get(pageDic).ContainsKey(mcid))
                {
                    tagContent = parsedTags.Get(pageDic).Get(mcid);
                }
            }
            else
            {
                PdfObjRef objRef  = (PdfObjRef)kid;
                PdfObject @object = objRef.GetReferencedObject();
                if (@object.IsDictionary())
                {
                    PdfName subtype = ((PdfDictionary)@object).GetAsName(PdfName.Subtype);
                    tagContent = subtype.ToString();
                }
            }
            @out.Write(EscapeXML(tagContent, true));
        }
示例#2
0
 /// <summary>Creates a tag that is referenced to the document's tag structure (i.e.</summary>
 /// <remarks>
 /// Creates a tag that is referenced to the document's tag structure (i.e.
 /// logical structure).
 /// </remarks>
 /// <param name="mcr">
 /// the
 /// <see cref="iText.Kernel.Pdf.Tagging.PdfMcr">Marked Content Reference</see>
 /// wrapper object
 /// </param>
 public CanvasTag(PdfMcr mcr)
     : this(mcr.GetRole(), mcr.GetMcid())
 {
 }