# Alternatives to tdclock / PDF viewers supporting tdclock

I tried to use tdclock package to embed a stopwatch in a beamer PDF file.

However, Adobe Reader is the only PDF viewer that can properly display the stopwatch/clock without those empty red boxes. Nevertheless, Adobe Reader is sluggish and crashes frequently when opening my presentation file.

In addition to embedding a stopwatch/clock, my presentation file has a movie (embedded by media9 package) which can be properly loaded/played in Adobe Reader and Foxit Reader. Unfortunately, Foxit Reader can't load tdclock stopwatch/clock and replaces it with empty red boxes despite enabling javascript and marking the file as safe.

My questions are:

1. are there any alternatives to tdclock package?
2. is it possible to fix the empty red boxes issue in Foxit Reader?
3. what is the PDF viewer that can properly load tdclock clock/stopwatch and play embedded movies flawlessly?
• Would you consider a presenter mode to be an alternative to the stopwatch? tex.stackexchange.com/questions/21777/… Jul 25 '16 at 13:41
• I couldn't open the link pympress.org . Does it work with you or I have a problem?
– Diaa
Jul 25 '16 at 14:06
• No, it does not work for me either. The source is available at github.com/Schnouki/pympress Jul 25 '16 at 14:14
• I'm voting to close this question as it is very similar to tex.stackexchange.com/questions/321075/… Jul 27 '16 at 19:52
• @sam I could provide an alternative clock implementation that also works in Foxit Reader and fixes some other tdclock issues (red boxes, asking for saving document upon closing). Jan 10 '18 at 14:00

Not a stopwatch, but another digital clock implementation showing the wall-time, working out of the box in AR and Foxit.

No empty red boxes in non-conforming PDF viewers, no save-the-changes dialog upon closing the document in AR and Foxit:

\documentclass{beamer}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Digital Clock
%
% Usage:
%
%   % set-up (defaults)
%   \def\clockfont{Helvetica} % or Times
%   \def\clockfontscale{0.93}
%   \def\clockformat{yyyy/mm/dd HH:MM:ss}
%   \def\clockrefresh{1000} % milli-seconds
%
%   % insert clock
%   \digiclock
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{pdfbase,xcolor}
\ExplSyntaxOn
\let\clockPdfAnnot\pbs_pdfannot:nnnn\let\clockPdfLastAnn\pbs_pdflastann:
\let\clockAppendToFields\pbs_appendtofields:n
\ExplSyntaxOff

\makeatletter
\def\clock@start#1#2#3{%
function showtime#3(){%
this.getField("digiclock.#3").value=util.printd("#1",new Date());%
this.dirty=false;%
}%
try{showtime#3();}catch(e){}%
try{app.clearInterval(digiclock#3);}catch(e){}%
try{var digiclock#3=app.setInterval("showtime#3()",#2);}catch(e){}%
}%
\def\clock@stop#1{try{app.clearInterval(digiclock#1);}catch(e){}}%
\newcounter{clock@num}%
\newlength\ex@height%
\newlength\clock@width%
\newlength\clock@height%
\def\digiclock{%
\settowidth\clock@width{\clockformat}%
\settoheight\clock@height{\clockformat}%
\settoheight\ex@height{X}%
\extractcolorspec{.}\clock@tempb% current color (\setcolor{...})
\expandafter\convertcolorspec\clock@tempb{rgb}\clock@tempb%
\edef\clock@tempa{\expandafter\clock@rgbcomp\clock@tempb\@nil}%
\raisebox{\depth}{%
\makebox[\clockfontscale\clock@width][l]{%
\clockPdfAnnot{\clockfontscale\clock@width}%
{\clockfontscale\clock@height}{\clockfontscale\clock@height}{%
/Subtype/Widget/FT/Tx/T (digiclock.\theclock@num) /Ff 1
/DA (/\clockfont\space 0 Tf \clock@tempa\space rg)
/MK<</BC []/BG []>>
/Q 2
/BS <</W 1/S/S>>
}%
\clockAppendToFields{\clockPdfLastAnn}%
%this is for Foxit compatibility: Widget annots don't seem to acknowledge /P* events;
%therefore, we move /AA into a separate Screen annot
\clockPdfAnnot{1ex}{0.5ex}{0.5ex}{%
/Subtype/Screen/F 2%
/AA <<%
/PO <</S/JavaScript/JS(\clock@start{\clockformat}{\clockrefresh}{\theclock@num})>>%
/PC <</S/JavaScript/JS(\clock@stop{\theclock@num})>>%
>>%
}%
}%
\vrule width 0pt height 0.5\ex@height depth 0.5\ex@height%
}%
\stepcounter{clock@num}%
}
\def\clock@rgbcomp#1,#2,#3\@nil{#1 #2 #3}
\makeatother
%default settings
\def\clockfont{Helvetica}
\def\clockfontscale{0.93}
\def\clockformat{yyyy/mm/dd HH:MM:ss}
\def\clockrefresh{1000}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%