Ejemplo n.º 1
0
 /// <summary>Adds a new tag to the tag structure.</summary>
 /// <remarks>
 /// Adds a new tag to the tag structure.
 /// This method call moves this
 /// <c>TagTreePointer</c>
 /// to the added kid.
 /// <br />
 /// New tag will have a role and attributes defined by the given
 /// <see cref="AccessibilityProperties"/>
 /// .
 /// This call is equivalent of calling sequentially
 /// <see cref="SetNextNewKidIndex(int)"/>
 /// and
 /// <see cref="AddTag(AccessibilityProperties)"/>
 /// .
 /// </remarks>
 /// <param name="index">zero-based index in kids array of parent tag at which new tag will be added.</param>
 /// <param name="properties">accessibility properties which define a new tag role and other properties.</param>
 /// <returns>
 /// this
 /// <see cref="TagTreePointer"/>
 /// instance.
 /// </returns>
 public virtual iText.Kernel.Pdf.Tagutils.TagTreePointer AddTag(int index, AccessibilityProperties properties
                                                                )
 {
     tagStructureContext.ThrowExceptionIfRoleIsInvalid(properties, currentNamespace);
     SetNextNewKidIndex(index);
     SetCurrentStructElem(AddNewKid(properties));
     return(this);
 }
Ejemplo n.º 2
0
        private PdfStructElem AddNewKid(AccessibilityProperties properties)
        {
            PdfStructElem kid = new PdfStructElem(GetDocument(), PdfStructTreeRoot.ConvertRoleToPdfName(properties.GetRole
                                                                                                            ()));

            AccessibilityPropertiesToStructElem.Apply(properties, kid);
            ProcessKidNamespace(kid);
            return(AddNewKid(kid));
        }
Ejemplo n.º 3
0
        internal virtual void ThrowExceptionIfRoleIsInvalid(AccessibilityProperties properties, PdfNamespace pointerCurrentNamespace
                                                            )
        {
            PdfNamespace @namespace = properties.GetNamespace();

            if (@namespace == null)
            {
                @namespace = pointerCurrentNamespace;
            }
            ThrowExceptionIfRoleIsInvalid(properties.GetRole(), @namespace);
        }
Ejemplo n.º 4
0
        internal static void Apply(AccessibilityProperties properties, PdfStructElem elem)
        {
            if (properties.GetActualText() != null)
            {
                elem.SetActualText(new PdfString(properties.GetActualText(), PdfEncodings.UNICODE_BIG));
            }
            if (properties.GetAlternateDescription() != null)
            {
                elem.SetAlt(new PdfString(properties.GetAlternateDescription(), PdfEncodings.UNICODE_BIG));
            }
            if (properties.GetExpansion() != null)
            {
                elem.SetE(new PdfString(properties.GetExpansion(), PdfEncodings.UNICODE_BIG));
            }
            if (properties.GetLanguage() != null)
            {
                elem.SetLang(new PdfString(properties.GetLanguage(), PdfEncodings.UNICODE_BIG));
            }
            IList <PdfStructureAttributes> newAttributesList = properties.GetAttributesList();

            if (newAttributesList.Count > 0)
            {
                PdfObject attributesObject   = elem.GetAttributes(false);
                PdfObject combinedAttributes = CombineAttributesList(attributesObject, -1, newAttributesList, elem.GetPdfObject
                                                                         ().GetAsNumber(PdfName.R));
                elem.SetAttributes(combinedAttributes);
            }
            if (properties.GetPhoneme() != null)
            {
                elem.SetPhoneme(new PdfString(properties.GetPhoneme(), PdfEncodings.UNICODE_BIG));
            }
            if (properties.GetPhoneticAlphabet() != null)
            {
                elem.SetPhoneticAlphabet(new PdfName(properties.GetPhoneticAlphabet()));
            }
            if (properties.GetNamespace() != null)
            {
                elem.SetNamespace(properties.GetNamespace());
            }
            foreach (TagTreePointer @ref in properties.GetRefsList())
            {
                elem.AddRef(@ref.GetCurrentStructElem());
            }
        }
Ejemplo n.º 5
0
 /// <summary>Adds a new tag to the tag structure.</summary>
 /// <remarks>
 /// Adds a new tag to the tag structure.
 /// This method call moves this
 /// <see cref="TagTreePointer"/>
 /// to the added kid.
 /// <br />
 /// New tag will have a role and attributes defined by the given
 /// <see cref="AccessibilityProperties"/>
 /// .
 /// </remarks>
 /// <param name="properties">accessibility properties which define a new tag role and other properties.</param>
 /// <returns>
 /// this
 /// <see cref="TagTreePointer"/>
 /// instance.
 /// </returns>
 public virtual iText.Kernel.Pdf.Tagutils.TagTreePointer AddTag(AccessibilityProperties properties)
 {
     AddTag(-1, properties);
     return(this);
 }
Ejemplo n.º 6
0
 internal DummyAccessibleElement(PdfName role, AccessibilityProperties properties)
 {
     this.role       = role;
     this.properties = properties;
 }