Class AlternateDescriptionResolver
java.lang.Object
com.itextpdf.html2pdf.attach.util.AlternateDescriptionResolver
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
resolve
(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElement
based on the attributes of theIElementNode
.protected void
resolveFallback
(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElement
based on the attributes of theIElementNode
in a fallback manner.protected boolean
resolveLink
(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElement
based on the attributes of theIElementNode
.protected boolean
resolveSvg
(com.itextpdf.svg.element.SvgImage accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theSvgImage
based on the attributes of theIElementNode
.
-
Constructor Details
-
AlternateDescriptionResolver
public AlternateDescriptionResolver()Creates a newAlternateDescriptionResolver
instance.
-
-
Method Details
-
resolve
public void resolve(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElement
based on the attributes of theIElementNode
.- Parameters:
-
accessibleElement
- theIAccessibleElement
to which the alternate description should be applied. -
element
- theIElementNode
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 theIAccessibleElement
based on the attributes of theIElementNode
. 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
- theIAccessibleElement
to which the alternate description should be applied. -
element
- theIElementNode
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 theIAccessibleElement
based on the attributes of theIElementNode
in a fallback manner.- Parameters:
-
accessibleElement
- theIAccessibleElement
to which the alternate description should be applied. -
element
- theIElementNode
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 theSvgImage
based on the attributes of theIElementNode
.If the alternate description is not found in the attributes, it is searched for the
tag the child nodes.- Parameters:
-
accessibleElement
- theSvgImage
to which the alternate description should be applied. -
element
- theIElementNode
from which the alternate description should be resolved. - Returns:
-
true
if the alternate description was resolved,false
otherwise.
-