コード例 #1
0
            public override void Draw(DrawContext drawContext)
            {
                LayoutTaggingHelper taggingHelper = GetProperty <LayoutTaggingHelper>(Property.TAGGING_HELPER);

                // We want to reach the actual tag from logical structure tree, in order to set custom properties, for
                // which iText doesn't provide convenient API at the moment. Specifically we are aiming at setting /ID
                // entry in structure element dictionary corresponding to the table header cell. Here we are creating tag
                // for the current element in logical structure tree right at the beginning of #draw method.
                // If this particular instance of header cell is paging artifact it would be marked so by layouting
                // engine and it would not allow to create a tag (return value of the method would be 'false').
                // If this particular instance of header cell is the header which is to be tagged, a tag will be created.
                // It's safe to create a tag at this moment, it will be picked up and placed at correct position in the
                // logical structure tree later by layout engine.

                TagTreePointer p = new TagTreePointer(pdfDocument);

                if (taggingHelper.CreateTag(this, p))
                {
                    // After the tag is created, we can fetch low level entity PdfStructElem
                    // in order to work with it directly. These changes would be directly reflected
                    // in the PDF file inner structure.
                    PdfStructElem structElem     = tagContext.GetPointerStructElem(p);
                    PdfDictionary structElemDict = structElem.GetPdfObject();
                    structElemDict.Put(PdfName.ID, headerId);
                    idTree.AddEntry(headerId.GetValue(), structElemDict);
                }

                base.Draw(drawContext);
            }
コード例 #2
0
        public virtual void AddKidsHint <_T0>(TagTreePointer parentPointer, IEnumerable <_T0> newKids)
            where _T0 : IPropertyContainer
        {
            PdfDictionary       pointerStructElem = context.GetPointerStructElem(parentPointer).GetPdfObject();
            TaggingDummyElement dummy             = existingTagsDummies.Get(pointerStructElem);

            if (dummy == null)
            {
                dummy = new TaggingDummyElement(parentPointer.GetRole());
                existingTagsDummies.Put(pointerStructElem, dummy);
            }
            context.GetWaitingTagsManager().AssignWaitingState(parentPointer, GetOrCreateHintKey(dummy));
            AddKidsHint(dummy, newKids);
        }