I am using the following code to set an alternate text for an image:
img.getAccessibilityProperties().setAlternateDescription(altText);
where img
is, of course, a com.itextpdf.layout.element.Image
When the text is non-ASCII (e.g. Hebrew or Russian) the alt text is displayed as gibberish. It seems that the high-order byte of the unicode char is simply stripped off - e.g. from 05EA, just EA enters the PDF. I know that PDF supports non-ASCII alternate text - how is it possible to create them using iText?
You must be using an outdated version of iText7
. There indeed was a bug with proper writing of alternate descriptions, but it was fixed in May 2017 and the fix is already available in the latest 7.0.4
release.
Please update to the latest version.