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-description attribute 5) aria-describedby attribute 6) aria-labelledby attribute
If none of the above attributes are present, the alternate description is not set.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidresolve(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElementbased on the attributes of theIElementNode.protected voidresolveFallback(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElementbased on the attributes of theIElementNodein a fallback manner.voidresolveLabelableElement(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element, ProcessorContext context) Resolves the alternate description of the labeledIAccessibleElementbased on the attributes of theIElementNodeandProcessorContext.protected booleanresolveLink(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElementbased on the attributes of theIElementNode.protected booleanresolveSvg(com.itextpdf.svg.element.SvgImage accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theSvgImagebased on the attributes of theIElementNode.
-
Constructor Details
-
AlternateDescriptionResolver
public AlternateDescriptionResolver()Creates a newAlternateDescriptionResolverinstance.
-
-
Method Details
-
resolve
public void resolve(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElementbased on the attributes of theIElementNode.- Parameters:
-
accessibleElement- theIAccessibleElementto which the alternate description should be applied. -
element- theIElementNodefrom which the alternate description should be resolved.
-
resolveLabelableElement
public void resolveLabelableElement(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element, ProcessorContext context) Resolves the alternate description of the labeledIAccessibleElementbased on the attributes of theIElementNodeandProcessorContext.- Parameters:
-
accessibleElement- theIAccessibleElementto which the alternate description should be applied. -
element- theIElementNodefrom which properties the alternate description should be resolved. -
context- theProcessorContextfrom 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 theIAccessibleElementbased 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- theIAccessibleElementto which the alternate description should be applied. -
element- theIElementNodefrom which the alternate description should be resolved. - Returns:
-
trueif the alternate description was resolved,falseotherwise.
-
resolveFallback
protected void resolveFallback(com.itextpdf.layout.tagging.IAccessibleElement accessibleElement, com.itextpdf.styledxmlparser.node.IElementNode element) Resolves the alternate description of theIAccessibleElementbased on the attributes of theIElementNodein a fallback manner.- Parameters:
-
accessibleElement- theIAccessibleElementto which the alternate description should be applied. -
element- theIElementNodefrom 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 theSvgImagebased 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- theSvgImageto which the alternate description should be applied. -
element- theIElementNodefrom which the alternate description should be resolved. - Returns:
-
trueif the alternate description was resolved,falseotherwise.
-