Forcing screen-reader read alt-text on a text element when creating a PDF in iText7

Is there any way to add alt text to a text element in iText? I have seen there is a way to do it for images. Basically, I would like the screen reader to read something besides the actual text that is being displayed. There are two situations in my document that I would need to do this.

One is when the screen-reader is reading an acronym I would like the alt-text to force the screen reader to read each letter instead of trying to read a word. (ie read DIET as D-I-E-T instead of diet)

The second is when it is reading a phone number I would like it to read outloud "phone" before the number. In the document it is currently just the number which would be a little confusing for disabled users. I am unable to actually change the layout to include the word "phone" for non-technical reasons.

1 answer

  • answered 2018-02-13 12:15 Joris Schellekens

    There is a method for that.

    new Paragraph("Lorem").getAccessibilityProperties().setActualText("Ipsum")

    You can call this method on every class that implements IAccessibleElement.