Sign up ×
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.

This year in my field we have a large conference overlapping with the European soccer championship. Luckily my talk does not overlap with any match, but in case it will happen in the future I was wondering if it is possible to include in a beamer presentation some Javascript magic that fetches the live results from the internet and displays them in the bottom bar.

I have researched and seen some examples of embedding JS in TeX, but everything seems to be only functions that do some simple stuff when the document is opened or when a PDF form is submitted. In particular, my questions at this point are:

  1. can I run AJAX requests inside a PDF, or are the security restrictions too tight?

  2. how do I embed code that gets called every X seconds, or whenever a new slide is presented?

  3. which packages would make my life easier in programming this?

share|improve this question

2 Answers 2

up vote 13 down vote accepted

Package media9 is an option.

The first example displays latest FIFA news in a Flash-based RSS-Reader I found on the web. It is embedded in the footline of every slide in a beamer presentation. It doesn't seem to update the content, though. However, it is reloaded (with updated content) when moving to the next presentation slide. Use next example's approach to force reloading at a given time interval.


  activate=pageopen, deactivate=pageclose,

\begin{frame}{Frame title}
Please concentrate on the slide content!

The second example loads an online chart image. It is displayed by StrobeMediaPlayback.swf shipping with media9. The image is updated in regular intervals of 10 s by repeatedly unloading and loading StrobeMediaPlayback.swf. Needs pdflatex for compilation.



\pdfannot width 0pt height 0pt depth 0pt {                                                                          
  /AA <</PO <<  %start updating routine on 'pageopen' event                                                                                                      
    /S/JavaScript/JS (                                                                                              
      try{var ret=app.setInterval('                                                                                 
      ' , 10000);}catch(e){}                                                                                        

share|improve this answer

One option is to use Lua to fetch data when the file is compiled. Then, set a batch script to recompile the TeX file every 30 seconds or so, and use a pdf reader that auto-refreshes the pdf file.

Here is an example (in ConTeXt) that fetches the current date and time at a specific location from a webserver, parses the returned XML file, and displays the result.

\enabledirectives[schemes.threshold=10] % Don't cache downloaded file for more than 10 sec

% I use earth tools as an example, which returns data in XML format.
  thirddata = thirddata or {}
  thirddata.url = ""

  function thirddata.getcurrenttime()
      -- Fetch remote url and store it in a file. ConTeXt automatically caches the
      -- file for a duration given by `schemes.threshold`
      local filename = resolvers.getreadfilename("loc",".", thirddata.url)

      -- Read the file for data
      local xmldata  = xml.load (filename)

      -- Parse XML find localtime
      local time = xml.text(xmldata, "xml://timezone/localtime")
      print("DEBIG:", time)

      return time


The current time is New York is \getCurrentTime.


Of course, if you are running a batch script to compile the file, you could as well get the data using any programming language of your choice, but where is the fun in that.

share|improve this answer

Your Answer


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.