Beispiel #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));
        }