Class AlternateDescriptionResolver

java.lang.Object
com.itextpdf.html2pdf.attach.util.AlternateDescriptionResolver

public class AlternateDescriptionResolver extends Object
Helper class for resolving the alternate description of an IAccessibleElement. The alternate description is resolved in the following order: 1) alt attribute 2) title attribute 3) aria-label attribute 4) aria-labelledby attribute

If none of the above attributes are present, the alternate description is not set.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new AlternateDescriptionResolver instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    resolve(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
    Resolves the alternate description of the IAccessibleElement based on the attributes of the IElementNode.
    protected void
    resolveFallback(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
    Resolves the alternate description of the IAccessibleElement based on the attributes of the IElementNode in a fallback manner.
    protected boolean
    resolveLink(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
    Resolves the alternate description of the IAccessibleElement based on the attributes of the IElementNode.
    protected boolean
    resolveSvg(com.itextpdf.svg.element.SvgImage accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
    Resolves the alternate description of the SvgImage based on the attributes of the IElementNode.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • resolve

      public void resolve (com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
      Resolves the alternate description of the IAccessibleElement based on the attributes of the IElementNode.
      Parameters:
      accessibleElement - the IAccessibleElement to which the alternate description should be applied.
      element - the IElementNode from which the alternate description should be resolved.
    • resolveLink

      protected boolean resolveLink (com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
      Resolves the alternate description of the IAccessibleElement based on the attributes of the IElementNode. If the link has an img tag as a child, the alt attribute of the img tag is used as the alternate description.
      Parameters:
      accessibleElement - the IAccessibleElement to which the alternate description should be applied.
      element - the IElementNode from which the alternate description should be resolved.
      Returns:
      true if the alternate description was resolved, false otherwise.
    • resolveFallback

      protected void resolveFallback (com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
      Resolves the alternate description of the IAccessibleElement based on the attributes of the IElementNode in a fallback manner.
      Parameters:
      accessibleElement - the IAccessibleElement to which the alternate description should be applied.
      element - the IElementNode from which the alternate description should be resolved.
    • resolveSvg

      protected boolean resolveSvg (com.itextpdf.svg.element.SvgImage accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element)
      Resolves the alternate description of the SvgImage based on the attributes of the IElementNode.

      If the alternate description is not found in the attributes, it is searched for the tag the child nodes.

      Parameters:
      accessibleElement - the SvgImage to which the alternate description should be applied.
      element - the IElementNode from which the alternate description should be resolved.
      Returns:
      true if the alternate description was resolved, false otherwise.