# Is PDF capable of conditional display and, if so, how can I achieve it with pdfTeX/friends?

Most of the time, we (or more conservatively, I) think of PDF as a static format fit for printing. I've been surprised in the past at how versatile it is -- how dynamic and interactive it can be -- so I've decided to ask the following.

I'd like to create a multi-lingual document where the language can be determined at run-time. That is, the user could select from a drop-down / radio button group to choose a language, and the relevant content would be appropriately substituted throughout the document.

If this is possible, my ideal interface/MWE would be:

\documentclass{whatever}
\usepackage{mwe} % just for \kant and \lipsum

\DeclareLanguageChoices{kant={One of Kant's Books},
psuedo-latin={Classical gibberish used in typesetting.}}

\begin{document}
\dochoices

\begin{LanguageChoice}

\BeginLanguage{kant}
\kant
\EndLanguage{kant}

\BeginLanguage{psuedo-latin}
\lipsum
\EndLanguage{psuedo-latin}

\end{LanguageChoice}
\end{document}


The syntax above is LaTeX, but solutions in pdfTeX, XeTeX, ConTeXt, and LuaTeX are all most welcome; just adapt it to the format of your choice. :-)

With this syntax, the produced PDF would display some sort of control at the top (at \dochoices) using the display text (that which is in {}) and, depending on the selected key, display the appropriate content.

### Thoughts on Potential Solutions

• I don't think the format can re-flow itself even vertically, so just taking the maximum box size would be necessary and sufficient.
• More as I / the comments think of them.
-

1. Layers/Optional Content Groups (OCGs). If you load the microtype manual in Adobe Reader you will see the effects e.g. on page 4. There are LaTeX packages for this (check the tag) and can create them easily. Note that few viewers but Adobe Reader and Acrobat support OCGs.