TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the tdclock package to display the current date and time. In looks pretty good in Acrobat, but in other viewers (like Evince) it looks terrible because they don't support Javascripts and instead they show a red box (see below).

\documentclass{article}
\usepackage{tdclock}
\begin{document}
\initclock

Date: \tddate

\end{document}

Is there a way to conditionally use one rendering or the other depending on whether one is using Acrobat to view the document. Or more specifically use one if Javascript is supported or another one if not?

Is something like this following posible?

\documentclass{article}
\usepackage{tdclock}
\begin{document}
\initclock
% not real code:
\ifJavascriptSupported{\tddate}{\today} % should show dynamic date in Acrobat, and static data in Evince
\ifJavescriptSupported{\tdchorno}{}

\end{document}

Another way of interpret this question is to allow alternative text if the viewer doesn't support a feature (like media9 does). (If nothing else, even no text at all will be better than a red box.)

Here it is a comparison with Acrobat and Evince with the current code:

Acrobat (numbers typeset by Javascript, no TeX):

acroread

.

Evince (ugly red boxes):

evince

.

Desired result in reader not supporting JS (static data shown in Evince, similar to \today)

evincetarget

share|improve this question
    
Note that testing for Acrobat is a bad idea because users may well have disabled (or not enabled) Javascript through preferences. – cfr Mar 20 '14 at 1:23
    
@cfr, that is part of the question. If Javascript is disabled in Acrobat then an alternative (fallback) code would appear. media9 is able to do that (but for media not Javascript). – alfC Mar 20 '14 at 1:24
    
What I meant was, you need the test to be for JS. In your question, you suggested 2 possibilities: test for A; test for JS. I just meant only the second would really work. By the way, it fails in Okular, too. – cfr Mar 20 '14 at 1:35
    
The only way I can think to do this is using OCGs (optional content groups) which are unfortunately also not consistently implemented in all PDF viewers. – Paul Gessler Jan 11 '15 at 2:53
up vote 0 down vote accepted

This is a partial solution to the problem, which at least eliminates the ugly red box that is rendered in PDF viewers with no Javascript support (including Acrobat when has it disabled).

By chance I found a hidden option of hyperref here http://tex.stackexchange.com/a/79979/1871 called Fld@bordercolor.

\documentclass{article}
\usepackage{tdclock}

\makeatletter
\def\Fld@bordercolor{1 1 1} % set TextField border to white, there is also Fld@bcolor
\makeatother

\begin{document}
\initclock

Date: \tddate

\end{document}

The place of the date will show just empty space (almost, there are couple of slashes remaining) if Javascript is disabled.

share|improve this answer

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.