Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need the generated PDF to have "alt" text associated with each image so that a screen reader can read the alt text to the visually impaired user. I understand that essentially just including the "alt" text as the caption, or as part of the caption would be sufficient in reality, but we are dealing with government legal requirements and it would be far easier to be able to just check that box.

Has anyone done this? Any help appreciated. Thanks.

share|improve this question
add comment

3 Answers

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}
share|improve this answer
add comment

You can use PDF tooltips with the pdfcomment package. Then the 'alt' text (aka tooltip) is read!

\documentclass{article}
\usepackage{graphicx}
\usepackage{pdfcomment}
\pagestyle{empty}

\begin{document}
one two three

\pdftooltip{\includegraphics{img.png}}{This is the ALT text}%

four five six
\end{document}
share|improve this answer
add comment

If you're up for creating an accessible version that is different from the regular version, the following elementary usage of text/graphics overlapping provides appropriate reading using Adobe Reader:

enter image description here

\documentclass{article}
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\makeatletter
\newcommand{\imagewithtext}[3][]{% \imagewithtext[<option>]{<text>}{<image>}
  \rlap{#2}% Print <text> in zero-width, right-overlap box
  \includegraphics[#1]{#3}% Print <image> with <options>
}
\makeatother
\begin{document}
There is a \imagewithtext[width=2em]{kitty}{tiger} in the brush.
\end{document}

AR picks up and reads There is a kitty in the brush. Depending on the images used, such text with either be visible or not. It would be possible to redefine \imagewithtext to gobble #2 (or the provided <text>).

share|improve this answer
    
Nice trick, overlaying the image with text. However, in my experiments the text had to be on top to be recognized. I have edited my answer for a refined version that does not fit in this comment. –  Heiko Oberdiek Oct 3 '12 at 5:43
    
@HeikoOberdiek: I had the same problem, but thought it had to do with the resizing of the text - also fitting it within the image box width. Didn't think about overlaying it on top though. –  Werner Oct 3 '12 at 14:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.