3

For fun, is it possible to launch a program by clicking on a link in a pdf? In this particular case, for a Physics lesson, I'll use a scenario of Poly Bridge game. It's installed and runs. But how do I include it in a clickable launcher in my document? Here is an MWE based on a video launcher with hyperref package, but other solutions are welcome too.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{lipsum}

\usepackage{hyperref} \begin{document} \lipsum[1-2] \begin{center}
\includegraphics[width=0.4\linewidth]{example-image-A}\par\medskip Here you can launch the game : \href{run:Steam/Poly Bridge}{Poly Bridge} \end{center} \end{document}

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Piroooh
  • 1,197
  • 2
    Hm, I first thought that it might be possible using JavaScript, but I guess, due to security concerns, it is probably not possible to open arbitrary files via clicking in a PDF. However, it is possible to open other PDFs or URLs, so maybe there is some kind of workaround. – Jasper Habicht Jul 06 '22 at 11:37
  • 2
    support for run is highly dependent on the pdf viewer being used. – David Carlisle Jul 06 '22 at 11:56
  • 2
    If a file is associated with some application linking this file with run: normally starts the application (after a security question) in adobe reader, so \href{run:file.tex} start my editor. Launching an application directly normally doesn't work, I think the reader blocks that. – Ulrike Fischer Jul 06 '22 at 12:34
  • I guess it can be blocked for security reasons. I've already launched video files with such applications of run. But for games... It's more direct. I'll let the question open but I could accept it's not possible to do that with pdf (: Thank you for your comments and for corrections. – Piroooh Jul 06 '22 at 14:39
  • You may be able to work around this by creating a shell script / batch file and use run on it instead. This would be conditional on your OS associating .sh or .bat files with "executing it in a command line". – Willie Wong Jul 06 '22 at 18:58
  • It may be possible to specify (in PDF) the application used to open a given file. See https://tex.stackexchange.com/questions/6376/how-to-create-a-link-in-a-pdf-document-to-open-a-file-using-a-specified-applicat?rq=1 for an example. – Willie Wong Jul 06 '22 at 19:00

0 Answers0