Like a thumbnail for a YouTube video, other interactive content can benefit from a still image for use with static formats. Our strategy is to render the content with a “headless” web browser and capture an image automatically. For example, you might write some custom Javascript to allow a reader to interact with a graph, and you would like an image of the graph, along with its interactive sliders and checkboxes, to appear in the
PDF version of your text. Recognize that this image will necessarily be the content at its initial start-up. Get a screenshot manually if you want something better.
Note that for all this to work, you need to properly serve your project’s
HTML output with the interactive content. (A local server may be a possibility, but we have not tried. See
Section 5.11. Or you can try a temporary public server, see
Section 5.12). Then you need to announce the location of this hosted
HTML, which is accomplished via a “base URL” in a publication file. Start at
Subsection 29.1.5 for details on this publisher variable. Note that the chunk level in your publication file used in this process
must match the chunk level used when you build your
HTML output, and mismatches for other publisher variables could have some ill effects.
The automatic screenshots will then be managed by the Python
playwright
package, which you will need to have installed in your Python virtual environment (see
Section C.3).