Reading the PDF specification I would have thought, that something like
\documentclass{article}
\usepackage{graphicx}
\usepackage{accsupp}
\pagestyle{empty}
\begin{document}
123
\BeginAccSupp{method=plain,Alt={Hello}}%
\includegraphics{img.png}%
\EndAccSupp{} %
456
\BeginAccSupp{method=plain,ActualText={world},space}%
\includegraphics{img.png}%
\EndAccSupp{} %
789
\end{document}
would work. However, AR10/Win reads:
area code one two three four five six seven eight nine
without Hello and world.
Therefore I would be interested in a PDF file for analyzing that actually works.
Werner's method with overlaying text
- In my experiments the text needed to be on top of the image, otherwise the PNG image (without transparency) suppressed the text that is overprinted by the image (AR10/Win).
- Transparency is used to make the text invisible.
- Additionally I have scaled the text to fit the width of the image to avoid longer text descriptions to fall of the page. But further experiments and testing with different screen readers would be useful to get the best strategy.
Example file:
\RequirePackage{cmap}% to get the ligature `fi' right
\documentclass{article}
\usepackage{color}
\usepackage{graphicx}
\usepackage{transparent}
\newsavebox\imagebox
\newcommand*{\imagewithtext}[3][]{%
\sbox\imagebox{\includegraphics[{#1}]{#2}}%
\usebox\imagebox
\llap{%
\resizebox{\wd\imagebox}{\height}{%
\texttransparent{0}{#3}%
}%
}%
}
\begin{document}
first \imagewithtext{img.png}{Hello world} last
\end{document}
\BeginAccSupp{ActualText=image replacement text,space}\EndAccSupp{}\includegraphics{img.png}seems to work fine with the Jovie text-to-speech plugin inokularand also withpdftotext. (Although something like Jaws won't recognise it as an alt-tagged image.) – Nicola Talbot Feb 14 '15 at 13:54